When it comes to calling a method in JavaScript, there are two main ways:
- myFunc(params);
- obj.myFunc();
Now, let's delve into some questions surrounding these methods:
- What exactly is the difference in accessing values (for params/obj) inside myFunc() for each of these approaches?
- In the first case, if we use "this" inside myFunc(), it would refer to the global object (window). But how does "this" behave in the second case?
- What are the different use cases for opting for one of these techniques over the other?
Feel free to mention any other significant distinctions between these two calling methods as well.