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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:19:04+00:00 2026-06-02T23:19:04+00:00

Looking under the hood in UnderscoreJS, I see: _.isFunction = function(obj) { return toString.call(obj)

  • 0

Looking under the hood in UnderscoreJS, I see:

  _.isFunction = function(obj) {
    return toString.call(obj) == '[object Function]';
  };

  _.isString = function(obj) {
    return toString.call(obj) == '[object String]';
  };

  _.isNumber = function(obj) {
    return toString.call(obj) == '[object Number]';
  };

This seems like an odd choice. Why not just use typeof to determine whether a value is a string, function, or number? Is there a performance gain by using toString? Is typeof not supported by older browsers?

  • 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-02T23:19:05+00:00Added an answer on June 2, 2026 at 11:19 pm

    Well actually this is because it is faster to check the [[Class]] by checking with toString. Also there could be less mistakes, since toString gives you the exact Class …

    check this :

    var fn = function() { 
        console.log(typeof(arguments)) // returns object
        console.log(arguments.toString()) // returns object Arguments
    }
    

    You could see the benchmark for underscore typeof vs toString here :

    http://jsperf.com/underscore-js-istype-alternatives

    Also there are some github issues with better explaination :

    https://github.com/documentcloud/underscore/pull/332

    https://github.com/documentcloud/underscore/pull/321

    EDIT 1 :

    You could also check this great article :

    http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/

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

Sidebar

Related Questions

I've been playing around to see how my computer works under the hood. What
I'm looking for some static library or open source project (in obj-c, released under
I'm looking for a way to put several of my projects under version control,
I am looking for a very similar solution described under Q: How to get
I am looking for jQuery plugin that will open an html under an input
I'm looking to test system responsiveness etc. on a few machines under certain CPU
I am looking for the Win32 binary version of Aspell 0.6. I am under
Is it possible to create an interactive cmd under Windows? I am looking for
I am looking for a family of hash function F1,..Fn, where each Fi maps
I'm looking to see if there is a method or tool to view how

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.