- Chrome: V8
- Firefox: SpiderMonkey
- Microsoft Edge/ Internet Explorer: Chakra/ChakraCore
Dynamic Typing: The interpreter figures out the type of the variable dynamically based on certain conditions. Primitive Data Types: The primitive data types are the data types that have no methods attached to it i.e. some defined methods cannot be used with them and they are used in isolation. Though there are ways to use those methods by wrapping these primitive data type variables (covered in the next article). The following are the data types that come under the primitive category:
- undefined: If variable exists but is not defined then it is categorized under undefined.
- null: If variable exists but is not explicitly set then it comes under null category.
- boolean: Boolean represents a logical entity and can have two values: true, and false.
- number: The number is the data type to define a number which can be integer, floating-point, double. The only problem here is that we have to allocate a memory equivalent to a double variable every time we define a number.
- string: This is used to define string values of a character.
- symbol: This is a special data type which is new in ECMA Script 6. The data type “symbol” is a primitive data type having the quality that values of this type can be used to make object properties that are anonymous.
Output: 2.Using Object literal
Output: 3. Creating object with Object.create() method:
Output: 4. Using es6 classes:
- Explicit Coercion Explicit coercion is the process by which we explicitly define a variable to a data type.
- Implicit Coercion Implicit Coercion is the process by which the interpreter dynamically type casts the variable under certain conditions.
- Creation Phase: Before executing the code, the engine reads through the entire file and will throw a syntactic error if one is found. While it does that, any function definitions will just be saved in memory. Any variable initialization will not be run but variable names will be declared.
- Execution Phase: The execution phase is the phase in which the code is run and hence the above variable hoisting example errors as undefined since, in the creation phase, the variable has been declared but not defined in the creation phase.
This article is contributed by Mukul Latiyan. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.