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

  • SEARCH
  • Home
  • 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 8113175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:44:36+00:00 2026-06-06T02:44:36+00:00

I am having some trouble wrapping my head around this function: var toStr =

  • 0

I am having some trouble wrapping my head around this function:

var toStr = Function.prototype.call.bind( Object.prototype.toString );
toStr([]) // [object Array]​​​​​​​​​​​​​​​​​​​​​​​​​​​

How does this function accept an argument as seen in line 2?

  • 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-06-06T02:44:38+00:00Added an answer on June 6, 2026 at 2:44 am

    Well,

    • Function.prototype.call references the “call” function, which is used to invoke functions with chosen this values;
    • The subsequent .bind refers to the “bind” function on the Function prototype (remember: “call” is a function too), which returns a new function that will always have this set to the passed-in argument.
    • The argument passed to “bind” is the “toString” function on the Object prototype, so the result of that whole expression is a new function that will run the “call” function with this set to the “toString” function.

    The result, therefore, is like this code: Object.prototype.toString.call( param ). Then, the “console.log” call passes that function an array, and there you have it.

    edit Note that Object.prototype.toString.call( param ) is like param.toString() really, when “param” is an object. When it’s not, then the semantics of the “call” function are to turn it into one in the normal ways JavaScript does that (numbers -> Number, strings -> String, etc).

    edit, 24 May2016 — That last sentence above is not accurate with ES2015. New JavaScript runtimes do not “autobox” primitive types when those are involved with a function call as a this value.

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

Sidebar

Related Questions

I am currently having some trouble wrapping my head around this issue. I had
Having a bit of trouble wrapping my head around Qtimer this morning. Here's the
I am having some trouble wrapping my head around virtual proxies. I have read
I'm new to backbone.js and having some trouble wrapping my head around an issue
I am having some trouble wrapping my head around noexcept. template <int SIZE> int
Im having some trouble writing a getstring function, this is what I have so
I'm having some troubles wrapping my head around how to go about parsing some
I'm having trouble wrapping my head around a query. I have the following 3
I'm having trouble wrapping my head around what should be a simple solution. I
I'm having trouble wrapping my head around Events and their Handlers in general. I

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.