DEV Community

HÈRMËS
HÈRMËS

Posted on

Understanding JavaScript with everyday life.

Explaining passing by reference type using real life situations: if two siblings let's say a boy and a girl likes to eat cereal "coco pops" and the boy buys it stores it in a shelf, because the girl (other sibling) likes it too so she goes to the same shelf and gets the "cocopops". This little illustration shows that the two parties who are entirely different entities share the same cereal from the same location. So does objects, they can use values and information from the same memory location.
When it comes to passing by value, the two siblings will have a cereal box each to their names and will store them at the location of their choices. #myFirstPost

Top comments (0)