Stack and Heap Memory

Stack memory is the space allocated for a process where all the function calls, primitive data types (int, double, string...)
VS
Heap memory is used to store the objects that are created during the execution of a program.
Thanks for concepts about reference vs primitives type and heap/stack too! 3:39 string is primitive (copy by value) 6:47 object ,array are references type 7:05 primitives are store on stack 7:35 references are store on heap (take longer to access, store bigger amount of data) 8:40 stack (store like stack 'push on top') 9:16 heap (store pointer) 10:48 it assign a pointer not value 14:50 Object.assign create new object and merge with existing one 16:07 Object.assign doesn't deep clone 17:26 may use Lodash to clone instead 19:04 copy array






Element (object) is created in the heap which store the actuall object, But we do have a pointer on the stack which stores the reference ,the address to this object in the heap and the variable simply store the pointer. The varaible doesn't know the address of the place in memory where our object is stored but the variable knows where the pointer lies on the stack it knows the position of the pointer on the stack an the pointer in turn simply stores the address of the object in the heap.






