First seven data types except object are primitive data types.
BigInt is necessary for big numbers because they are unreliable with Number type
example below:
console.log(9999999999999999); // 10000000000000000
console.log(9999999999999999n); // 9999999999999999n
Objects, including instances of data types, can have properties, stored information. The properties are denoted with a . after the name of the object, for example: 'Hello'.length.
Objects, including instances of data types, can have methods which perform actions. Methods are called by appending the object or instance with a period, the method name, and parentheses. For example: 'hello'.toUpperCase().
We can access properties and methods by using the ., dot operator.
Built-in objects, including Math, are collections of methods and properties that JavaScript provides.
Properties of an object can be either a value, or a method (a function only accessible to an instance of the object). A method is an attribute, but that does not make an attribute a method. A method is function, so performs some task. .length is a value, only.
String.prototype.trim() = method removes whitespace from both ends of a string and returns a new string, without modifying the original string
What does it mean by an instance of a data type?
a = 42
Above we assign an integer value (a number) to the variable, a. When we poll the type of a we are actually polling the type of 42. a is not an object, but a reference to an object. 42 is identified by the interpreter as being a number type so gives it a wrapper object of that type.
typeof 42 => 'number'
typeof a => 'number'
So a refers to an instance of a number type.
Top comments (0)