What are Data Types?
- There are 7 primitive data types:
Objectdata type is not considered a primitive — and will be covered in a separate post
A string is a sequence of textual characters
Each character in a string has a given position, formally known as an index. To access a character in a string, we specify its index as an integer (starting from 0)
let firstLetter = lang;
console.log(firstLetter); // Output: "J"
Number is an integer or whole number without a decimal point
let value = 123;
A float or floating-point number is a
Number with a decimal point
let value = -1.23;
Boolean is logical data type that can only return a
let isAdmin = true;
Undefined is a data type which describes the absence of a value. This usually happens when a variable is declared but never initialized (i.e. no value was assigned)
console.log(age); // Output: undefined
BigInt is a data type used to store integer values that are too big to be represented by a
let totalSum = 9999999999;
Null data type is used to indicate the absence of an object. It is a data type which can only be initialized by a human — never the result of a function.
let num = null;
console.log(num); // Output: null
Symbol is a unique and immutable value (cannot be changed) which is used to create unique property keys so that they don’t…