What will each of the console.log will print out, and Why?
The previous question is based on knowing varying evaluation strategies. What is the difference between Pass-By-Value evaluation and Pass-By-Reference evaluation strategies?
Which strategy does Javascript's evaluation strategy fall under? How?
What is the difference between Mutating vs Rebinding?
Answer to #1
What will each of the console.log will print out, and Why?
The previous question is based on knowing varying evaluation strategies. What is the difference between Pass-By-Value evaluation and Pass-By-Reference evaluation strategies?
Answer:
Pass-By-Value
In this strategy, the value of the arguments that are passed into the functions are copies of the valuesof the objects and primitives passed by the invocation of the function.
Pass-By-Reference
In this strategy, the value of the arguments that are passed into the functions are direct pointers to the objects and primitives passed by the invocation of the function.
Answer to #3
Which strategy does Javascript's evaluation strategy fall under? How?
Answer:
Neither. Javascript falls under Call-By-Sharing
Call-By-Sharing
In this strategy, the value of the arguments that are passed into the functions are copy of the reference(pointer) to the objects and primitives passed by the invocation of the function.
Answer to #4
What is the difference between Mutating vs rebinding?
Answer:
Mutating
In contrast with rebinding, mutating only affects the content of the object, not the connections between the variable pointers and the object itself.
obj.name = "mutation"
Rebinding
Rebinding is the process by which a variable that previously pointed to an object now points to another object via reassignment.