JavaScript has several data types −
- Number: Represents numeric values, including integers and floating-point and double numbers. Eg. 123, 123.45
- String: Represents a sequence of characters, including letters, numbers, and symbols, enclosed in single or double quotes.
Eg. “hello World”, “this is String”
- Boolean: Represents either true or false.
- Undefined: Represents a variable that has been declared but has not been assigned a value.
- Null: Represents an intentional non-value.
- Object: Represent complex data structures such as arrays, dates, and more.
- Symbol: A new data type introduced in ECMAScript 6, used to create unique and immutable identifiers.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// Primitive data types var string = "Hello, World!"; var number = 42; var boolean = true; var nullValue = null; var undefinedValue = undefined; // Object data type var object = {key: "value"}; var array = [1, 2, 3]; var functionExpression = function () {}; var date = new Date(); var regex = /ab+c/; |