Types in JavaScript
In JavaScript, we have two types of data types:
1. Primitive Types: These include string, number, boolean, null, undefined, and
symbol.
2. Reference Types: These include objects and arrays.
Objects and Properties in JavaScript
Objects are key-value pairs where the keys are strings and the values can be any
data type. These keys are also known as properties. For example:
let person = {
name: 'John Doe',
age: 30,
isStudent: false
};
In this example, name, age, and isStudent are properties of the person object.
JavaScript Syntax and Basics
JavaScript uses curly braces {} to define objects and blocks of code, and
parentheses () for function calls and expressions. Semicolons ; are used to end a
statement.
Variables in JavaScript
Variables are used to store data. In JavaScript, we use the let keyword to declare
variables. For example:
let message;
message = 'Hello World';
console.log(message);
Constants in JavaScript
Constants are variables that cannot be reassigned a new value. We use
the const keyword to declare constants. For example: