Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6468755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:55:09+00:00 2026-05-25T05:55:09+00:00

Function.prototype.bind = function() { var _this = this, original = _this, args = Array.prototype.slice.call(arguments),

  • 0
Function.prototype.bind = function() {
    var _this = this,
        original = _this,
        args = Array.prototype.slice.call(arguments),
        _obj = args.shift(),
        func = function() {
            var _that = _obj;
            return original.apply(_that, args.concat(
            Array.prototype.slice.call(
            arguments, args.length)));
        };
    func.bind = function() {
        var args = Array.prototype.slice.call(arguments);
        return Function.prototype.bind.apply(_this, args);
    }
    return func;
};

I know it’s a bind function. But I don’t understand it and what it’s doing, specifically the args.concat part. What does concat do? Also, what does .bind method do that .apply and .call can’t?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T05:55:10+00:00Added an answer on May 25, 2026 at 5:55 am

    The bind function takes a function and ensures that it is always bound to a specific this value. The easiest example is in event handlers. By default, event handler’s this value is bound to window. However, let’s say that you want to use an object’s method as a listener, and in that listener change some properties:

    var thing = {
        answer : 4,
        listener : function() {
            this.answer = 42;
        }
    }
    window.onload = thing.listener;
    

    On the onload event, instead of thing.answer being changed like intended, window.answer is now 42. So, we use bind:

    window.onload = thing.listener.bind(thing);
    

    So, bind returns a function, that when called, calls the original function, but with the specified this value.

    [].concat simply adds the arguments to the array – so [].concat(5, 4) returns [5, 4], and [5, 4].concat([42]) returns [5, 4, 42]. In this case, it is used to concatenate arguments – you can pass arguments to the bind function that’ll be passed as arguments when the function is called. The concatenation works so that when you call the binded function, the arguments you pass now are also passed along.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return
Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return
From: http://ejohn.org/apps/learn/#2 Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object =
i have seen this code: Function.prototype.bind = function (bind) { var self = this;
TL;DR: Adding any non-built-in functions to Array.prototype AND Function.prototype will cause the IE8 native
I have seen a function whose prototype is: int myfunc(void** ppt) This function is
When I want to call a function in javascript with arguments supplied from elsewhere
I am trying to incorporate prototype.js's bind() function into my Flash component. I found
I currently have a partial-application function which looks like this: Function.prototype.curry = function() {
I've got pretty interesting question about EcmaScript-5 Function.prototype.bind implementation. Usually when you use bind,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.