The Startup
Published in

The Startup

Photo by Roman Synkevych on Unsplash

Let Us Understand Binding Concepts Once and for All.

  1. bind()
  2. call()
  3. apply()
  1. You have two objects employee1 and employee2. Employee1 has salaryHike function which you want to use on employee2.
  2. Every function has it’s own this function and currently, salaryHike’s this refers to employee1 object and you want it to change to employee2.
  3. So what we did is we used call method and passed on the object we wanted salaryHike’s this should refer to and execute the function.
  4. Which increased $10,000 hike of employee2 salary.
  1. Have a function defined inside the object.
  2. Have a function in the global scope and bind it to other objects.

--

--

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +768K followers.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Divyesh

Full Stack Developer | Working on my Startup | Loves Building weird stuff | Trying to get better at Writing and articulating my thoughts |