JavaScript (JS) Basics
JavaScript (JS) Basics
and server-side that allows you to make web pages interactive. It is one of the three
core technologies of World Wide Web content production, alongside HTML and CSS.
● Data types: JavaScript has seven primitive data types: undefined, null,
Boolean, number, string, object, and symbol.
● Variables: Variables are used to store data. To declare a variable, you use the
var keyword. For example:
JavaScript
var name = "Alice";
JavaScript
const PI = 3.14;
JavaScript
// Arithmetic operator
var sum = 1 + 2;
// Comparison operator
var isGreaterThan = 1 > 2;
// Logical operator
var isTrue = 1 > 2 && 2 > 3;
greet("Alice");
JavaScript
var person = {
name: "Alice",
age: 25
};
console.log(person.name); // "Alice"
JavaScript
var numbers = [1, 2, 3, 4, 5];
console.log(numbers[2]); // 3
JavaScript
if (name === "Alice") {
console.log("Hello, Alice!");
} else {
console.log("Hello!");
}
Use code with caution. Learn more
content_copy
This is just a basic overview of JavaScript. There is much more to learn, but this
should give you a good starting point.