Functions inside the prototypes

So, why the splice function is performing an operation on the topping array/object because as you can see clearly that I have called the splice for the extra array/object.
is the variable extra acting like a pointer here or something ???

Try logging this in both your constructor, and your prototype method. Do they refer to the same thing?

Ok, so i did some google search and find out this
Variables that are assigned a non-primitive value are given a reference to that value. That reference points to the object’s location in memory. The variables don’t actually contain the value.

So, according to the statement this behaviour is correct because

Objects are created at some location in your computer’s memory. When we write arr = [] , we’ve created an array in memory. What the variable arr receives is the address, the location, of that array..

I hope i made this clear for you too for more info you can visit this article.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.