Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="This Keyword 9 hard binding using bind() method" />
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
if(!Function.prototype.bind2) {
  Function.prototype.bind2 = function(obj) {
    var fun = this;
    return function() {
      fun.apply(obj, arguments);
    };
  };  
}
function displayName(lastName) {
  console.log(this.name + " " + lastName);
}
var obj1 = {name: "Deepak"};
var obj2 = {name: "Chetan"};
var displayName = displayName.bind2(obj1);
displayName("Sisodiya");
displayName.call(obj2, "Sisodiya");
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
deepaksisodiyapro
0viewers