Nodejs Function Bind bind(scope)

Here you can find the source of bind(scope)

Method Source Code

// Copyright 2010 Mohamed Mansour. All rights reserved.
// Use of this source code is governed by a BSD-style license that can
// be found in the LICENSE file.

/**/*from  www .jav a  2 s.  c  om*/
 * Function extension for binding the current scope.
 * @param {Object} scope the scope to bind the function that is extended.
 */
Function.prototype.bind = function(scope) {
  var _function = this;
  return function() {
    return _function.apply(scope, arguments);
  }
};

/**
 * Trim the results from spaces from the beginning and end
 * @return {string} the trimmed string.
 */
String.prototype.trim = function () {
    return this.replace(/^\s*/, '').replace(/\s*$/, '');
};

Related

  1. bind(bind,args)
    Function.prototype.bind = function(bind,args){
      var self = this;
      var options = args;
      return function(){
        var args = (options != undefined) ? options.extend(arguments) : arguments;
        return (function(){
          return self.apply(bind || null, args);
        })();
    };
    
  2. bind(obj)
    Function.prototype.bind = function(obj) {
        var f = this;
        return function () {
      return f.apply(obj, arguments);
        };
    };
    
  3. bind(bind)
    Function.prototype.bind = function (bind) {
        var self = this;
        return function () {
            var args = Array.prototype.slice.call(arguments);
            return self.apply(bind || null, args);
        };
    };
    
  4. bindArg()
    Function.prototype.bindArg = function () {
        var args = arguments,
            that = this;
        return function () {
            that.apply(this, args);
        };
    };
    
  5. bind(a)
    Function.prototype.bind = function (a)
      if (arguments.length < 2 && typeof arguments[0] === 'undefined') return this;
      var b = this,
        c = Array.prototype.slice.call(arguments).slice(1);
      return function ()
        var d = c.concat(Array.prototype.slice.call(arguments));
        return b.apply(a, d)
    ...
    
  6. bind(scope)
    Function.prototype.bind = function(scope) {
      var _function = this;
      return function() {
        return _function.apply(scope, arguments);
    
  7. bindbind(self)
    Function.prototype.bind = function bind(self) {
      var callable = this;
      return function binding() { return callable.apply(self, arguments.toArray()); };
    
  8. bind(oThis)
    Function.prototype.bind = Function.prototype.bind || function (oThis) {
      if( typeof this !== "function" ) {
        throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
      var aArgs = Array.prototype.slice.call(arguments, 1),
        fToBind = this,
        fNOP = function () {},
        fBound = function () {
          return fToBind.apply(
    ...
    
  9. bind(scope)
    Function.prototype.bind = function(scope) {
        var func = this;
        return function() {
            return func.apply(scope, arguments);
        };
    };