Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Bind() In JavaScript

		  (function()
	  {
		
		const student =
		  {
			  name :'John',
			  getName : function()
			  {
				  return this.name;
			  }
		  }
		  
	let theName =student.getName.bind(student);
	console.log(theName());

	  })()
      /*use bind when you have a function(not one created from a class) that requires a this, and you add the this candidate inside of bind*/
Source by students.soyhenry.com #
 
PREVIOUS NEXT
Tagged: #In #JavaScript
ADD COMMENT
Topic
Name
7+6 =