Primitive Data Types
1. String - text (a sequence of characters), such as "hello world". String manipulation functions, such as
slice, and more are available. Strings can be concatenated using the
NaN are supported.
3. BigInt - a numeric data type introduced in ES2020, used to represent integers that are larger than the range of the standard Number data type. They are created by appending the letter "n" to the end of an integer literal or by using the
const bigNumber = 1234567890123456789012345678901234567890n; const anotherBig = BigInt('1234567890123456789012345678901234567890')
! to manipulate boolean values.
5. Undefined - a variable that has been declared but has not been assigned a value. Undefined values can lead to bugs in your code, and it is important to always initialize variables before using them:
let name; console.log(name); // prints: undefined
6. Null - a variable that has been explicitly assigned the value
null - represents the absence of any object value, often used to indicate the absence of a value.
let name = null; console.log(name); // prints: undefined
7. Symbol - (introduced in ECMAScript 6) a unique identifier that can be used as the key of an object property. Symbols are used to create unique identifiers for object properties.
Complex Data Types
- Object - a collection of properties, where each property consists of a key-value pair. Objects can be created using the object literal syntax, which looks like this:
- Function - a block of code that can be called by other parts of the code. They can be created using the function keyword, and can take parameters and return values. Functions are used to create reusable blocks of code for custom logic, perform calculations, manipulate data, and more.
!==) and to explicitly convert data types when necessary.