February 2018
Intermediate to advanced
298 pages
8h 22m
English
Primitive data types, such as Boolean, string, and number, have their constructor counterparts. These counterpart constructors behave like wrappers for these primitive types. For example, the String constructor is used to create a string object that contains an internal [[PrimitiveValue]] property that holds the actual primitive value.
At runtime, wherever necessary, the primitive values are wrapped with their constructor counterparts, and the counterpart objects are treated as primitive values so that the code works as expected. Consider this example code to understand how it works:
const s1 = "String"; const s2 = new String("String"); console.log(typeof s1); console.log(typeof s2); console.log(s1 ...Read now
Unlock full access