Nodejs Object Bind bind(method)

Here you can find the source of bind(method)

Method Source Code

Object.prototype.bind = function(method){
   var object   = this;
   return function(){
        method.apply(object, arguments);
    };/*from w  ww. ja  va 2 s.  c o m*/
}

Related

  1. bind(prop)
    Object.prototype.bind = function (prop) {
        var self = this;
        var method = this[prop];
        return function () {
      return method.apply(self, arguments);
        };
    };
    
  2. map(cb, thisArg)
    Object.prototype.map = function(cb, thisArg) {
      thisArg = thisArg || this;
      var that = this;
      Object.getOwnPropertyNames(this).map(function(name) {
        cb(name, that[name]);
      });
      return this;
    };
    
  3. map(f)
    "use strict";
    var map = function(f, thing) {
      if(thing.map) {
        return thing.map(f);
      throw new Error("Object given does not implement map");
    };
    var square = function(x) {
      return x * x;
    ...
    
  4. map(obj, callback)
    "use strict";
    Object.map = function(obj, callback) {
        return Object.keys(obj).map(key => callback(obj[key], key));