Relative Content

Tag Archive for objectthis

In applying bind() on an object, does Function Bound signify Error?

I have been using the this keyword for quite a while now but it has raised my curiousness to know much about it. I did a research and I came across a lengthy lessons and examples on the W3school site (https://www.w3schools.com/js/js_this.asp). Methods like call(), apply(), and bind() can refers the this keyword to any object. I declared few objects and called the call() and apply() methods on them, and I got exactly the output I was expecting to see in the console. In the below exercise, I declared two different objects with the first object(studentOne) containing a function. Using the bind() method; I have tried to borrow a method from the first Object(studentOne), in order to use it in the second object(studentTwo) and get the student full Name printed out in the console, but I keeps getting [Function: bound fullName] and undefined(when JSON.stringify() is apply). Can some please explain this behavior properly for me?