Number:
let num =10 console.log(typeof num); // Output: "number"
Definition: Represents numeric data, including both integers and floating-point numbers.
String:
let str = "Hello, World!"; console.log(typeof str); // Output: "string"
Definition: Represents a sequence of characters, enclosed within single quotes (
''
) or double quotes (""
).Boolean:
let isTrue = true; console.log(typeof isTrue); // Output: "boolean"
Definition: Represents a logical value, either
true
orfalse
, used for logical operations and conditions.Undefined:
let undefinedVar; console.log(typeof undefinedVar); // Output: "undefined"
Definition: Represents a variable that has been declared but has not been assigned a value.
Null:
let nullVar = null; console.log(typeof nullVar); // Output: "object"
Definition: Represents the intentional absence of any object value. It is often used to signify a deliberate non-existence or invalid reference.
Symbol:
let= Symbol('foo'); console.log(typeof sym); // Output: "symbol"
Definition: Represents a unique and immutable data type used to identify object properties. Symbols are often used as keys in JavaScript objects to avoid naming conflicts.
Object:
let= { key: 'value' }; console.log(typeof obj); // Output: "object"
Definition: Represents a collection of key-value pairs, where keys are strings (or Symbols) and values can be of any data type, including other objects.