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 7414299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:04:45+00:00 2026-05-29T07:04:45+00:00

I’m barely starting JavaScript and I’m wondering if there are any geniuses out there

  • 0

I’m barely starting JavaScript and I’m wondering if there are any geniuses out there that can help me understand this line by line?

1:  Function.prototype.bind = function(){
2:   var fn = this, 
3:      args = Array.prototype.slice.call(arguments), 
4:      object = args.shift();
5:   return function(){
6:   return fn.apply(object,
7:      args.concat(Array.prototype.slice.call(arguments)));
8:  };
9: };

I’m just beginner, but if you can teach me, then you’re awesome. I know about prototypes, call, shift, apply a bit so you can skip the beginner parts (though I think you shouldn’t so other who are barely getting into JS may learn how).

Notice: I know that there’s a somewhat “similar code” asking a similar question here but I’m asking line by line explanation and they’re not (not duplicate) (also, you can skip line 8 & 9) 🙂

  • 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-29T07:04:46+00:00Added an answer on May 29, 2026 at 7:04 am

    This is a partial implementation, in EcmaScript 3, of the EcmaScript 5 bind method which does partial application. It makes

    myObject.method.bind(myObject, 1, 2)(3, 4)
    

    is equivalent to

    myObject.method(1, 2, 3, 4)
    

    but its also more convenient because you can do

    var m = myObject.method.bind(myObject, 1, 2);
    m(3, 4);
    m(5, 6);
    

    instead of

    myObject.method(1, 2, 3, 4);
    myObject.method(1, 2, 5, 6);
    

    Nit: The two are not entirely equivalent, because if the first call to myObject.method does this.method = somethingElse; then the bound method would still call the original.

    To break it down:

    Function.prototype.bind = function(){
    

    Adds a method to the builtin function type.

    var fn = this, 
    

    Stores this which should be a Function in normal use so that it can be used inside a closure.

    args = Array.prototype.slice.call(arguments), 
    

    Creates an array containing the arguments to bind.

      object = args.shift();
    

    Removes the first argument from args and stores it in object. This will be used as the this value for fn when it is applied later.

     return function(){
    

    returns a function that acts as a partially applied method. This function when called

    return fn.apply(object,
    

    calls the function to the left of .bind passing the first argument to bind as this.
    apply is a special reflective method of functions which allows calling of a function with an array of arguments similar to *args or **kwargs in python, or ... in Java.

      args.concat(Array.prototype.slice.call(arguments)));
    

    passes as arguments to fn, the arguments to bind followed by the argument to the closure.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.