Java Script 1
Java Script 1
const values = ['Ace', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King'];
Primitive vs Reference
Let,var, const name = “Phani”, 70, true etc
Reference array, object, dict,
var person = {
name: 'Max',
age: 28,
}
var hobbies = ['Sports', 'Cooking']
difference = memory management
stack vs Heap
The stack is essentially an easy-to-access memory that simply manages its items
as a - well - stack. Only items for which the size is known in advance can go
onto the stack. This is the case for numbers, strings, booleans
For each heap item, the exact address is stored in a pointer which points at the
item in the heap. This pointer in turn is stored on the stack. That will become
important in a second.
Let,var,const on a object lets you to change the properties inside the object edit
delete add them, but you cant assign it a new object
When you say var array1 = [….] , then array2 = array1 you copy the pointer, to
copy the value of an reference type
You basically need to construct a new object or array and immediately fill it
with the properties or elements of the old object or array.
var hobbies = ['Sports', 'Cooking']
var copiedHobbies = hobbies.slice()