Starting With Javascript
Developed in 1995 by Brendan Eich at Netscape, it was initially called Mocha but later became LiveScript and finally JavaScript
Now, in today’s world, JavaScript has become the most popular language. Initially, it only ran on browsers, but later Brendan Eich made JavaScript run outside the browser by introducing JavaScript engines like Node, V8, SpiderMonkey etc.
JavaScript has 8 primitive data types
String
Number
Bigint
Boolean
Undefined
Null
Symbol
Object
Primitive data types in JavaScript represent the most basic, immutable values in the language. In simple words, we can say that the primitive size for this type of data is fixed
JavaScript non primitive type of data types
object
array
function
Non-primitive data types in JavaScript, also known as reference types, can store collections of values and complex entities. We can dynamically allocate memory space to non-primitive types of data.
In JavaScript, data is stored in two main ways: the stack and the heap. The stack is used for storing primitive data types, and it has a fixed size — we cannot increase or decrease its capacity dynamically. On the other hand, non-primitive data types such as objects and arrays are stored in the heap, which allows dynamic memory allocation.
To make access more efficient, JavaScript stores the reference (or address) of non-primitive data in the stack, while the actual data is stored in the heap. This way, when JavaScript needs to access non-primitive data, it simply looks up the reference from the stack and retrieves the data from the heap. This approach reduces the need to scan both the stack and heap, improving performance and efficiency.