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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:22:24+00:00 2026-06-08T19:22:24+00:00

In underscore.js, the following code seems to add _.isNumber() // Add some isType methods:

  • 0

In underscore.js, the following code seems to add _.isNumber()

  // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp.
  each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) {
    _['is' + name] = function(obj) {
      return toString.call(obj) == '[object ' + name + ']';
    };
  });

but there must be something else going on, because copying this code straight into firefox causes it to fail as toString.call(5) returns [xpconnect wrapped native prototype] — so its obviously doing something else somewhere – but I can’t figure out what.

Here’s an example of the results in firefox:

http://jsbin.com/uviyaz/2/edit

  • 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-08T19:22:27+00:00Added an answer on June 8, 2026 at 7:22 pm

    Your jsbin is showing window.toString, where as underscore is using Object.prototype.toString, they have aliased it to toString locally in their code.

    See http://jsbin.com/uviyaz/3/edit

    See also underscore’s source where they do it:

      // Create quick reference variables for speed access to core prototypes.
      var slice            = ArrayProto.slice,
          unshift          = ArrayProto.unshift,
          toString         = ObjProto.toString,
          hasOwnProperty   = ObjProto.hasOwnProperty;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code (with the Underscore.js library) to add the attributes target=_blank
What does the underscore mean in the following regex? [a-zA-Z0-9_] The _ seems to
In underscore.js the for each method starts with the following: var each = _.each
I am using the following code to load two underscore.js templates. Once the first
I'm using backbone.js, underscore.js and jQuery. I took the following sample code from http://jsfiddle.net/thomas/C9wew/6/
I came across the following line of code in the underscore.js source: function (obj,
Is there some framework similar to underscore that allows me to run async methods
I have the following HTML code inside a div: <a href=http://www.mysql.com> <img src=images/php-power-micro2.png alt=Image
I come across the following in code. _name1 _name2 smeEGiGross: In general, what does
Lastly I was skimming through Underscore.js code to learn JavaScript idioms and I found

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.