js bind example on function

function() this context controlled from bind keyword.

by David McClelland

JavaScript

var myModule = {
  name: 'David',
  getName: function() {
    return console.log(this.name);
  }
}

myModule.getName();

var someName = myModule.getName.bind({name:'Bob'});
someName();