Table of Contents
Numbers can be stored as a literal value or as a variable. They are typically used to carry out mathematical operations such as
02 of 06The Boolean values
When an expression is evaluated, the result is either true or false. Boolean values are often used in control structures to dictate the flow of a program and are responsible for deciding when certain code should be executed. Boolean values are also commonly used in the comparison of two values, such as when the equality of two things is evaluated.
For example, if two numbers are compared, it will return a Boolean value of true if the numbers are equal and false if the numbers are not equal
let number = 10; (number === 10) // true (number === 8) // false
03 of 06The special values
This immutability makes them ideal for storing data that will not be changed often, such as URLs and passwords. Strings can also be manipulated using methods such as .replace(), .indexOf(), and .substr(), which allow developers to easily alter, search, and update strings.
// Using double quotes: let string1 = "Using double quotes"; // Using single quotes: let string2 = 'Using double quotes';
// Single quote inside double quotes: let answer1 = "It's alright"; // Single quotes inside double quotes: let answer2 = "He is called 'Johnny'"; // Double quotes inside single quotes: let answer3 = 'He is called "Johnny"';
05 of 06A symbol
Symbols can be used to store properties and can be anonymous or have a name. Symbols can be used in the same way as strings and numbers, and are used in the same way as other primitive data types when creating and manipulating objects.
As a result, they are especially useful in creating and maintaining unique identities for objects in an application. Furthermore, Symbols can be used to make the properties of an object private, allowing developers to create secure and independent objects.
06 of 06An object
The typeof operator can be used to determine the type of a given value; this operator returns a string, such as
'symbol'. As an example, the
typeof operator applied value “46” will return the