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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:12:29+00:00 2026-06-10T12:12:29+00:00

Why does Modernizr do the following: toString = {}.toString,

  • 0

Why does Modernizr do the following:

toString = {}.toString,
  • 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-10T12:12:31+00:00Added an answer on June 10, 2026 at 12:12 pm

    It’s grabbing a local copy of the Object.prototype.toString method which would allow it to make small speed improvements in the script. This also allows it to test that the toString method exists.

    Regards to comments:

    Every name resolution there is a cost, in lookup-time (locals, globals, prototype-chaining) and creation (closure-scoped variable), so imaging the following code:

    var values = // Create some object here.
    
    for (var i = 0; i < count; i++) {
      console.log(values[i].toString());
    }
    

    For each iteration of the look we are having to resolve the values variable, and walk the prototype chain to identify the member toString, and then execute that.

    Taking that above example, we could do the following:

    var toString = {}.toString,
        values = // Create some object here.
    
    for (var i = 0; i < count; i++) {
      console.log(toString.call(values[i]));
    }
    

    Or even further:

    var toString = {}.toString,
        log = console.log,
        values = // Create some object here.
    
    for (var i = 0; i < count; i++) {
      log.call(console, toString.call(values[i]));
    }
    

    Light applications won’t really benefit too much from this, but larger frameworks, such as jQuery, etc, can improve the script performance quite significantly. IE I believe is one such browser where these small improvements can help quite a lot.

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

Sidebar

Related Questions

Does the following psuedo code accomplish my goal of cleaning up after myself when
Does Modernizr 2.0 beta have a way to detect browser support for @media queries?
Does the following function cause stack overthrow eventually? var isFinish= false; function foo(){ //
The following function should ensure that if a device does not have CSS3 abilities
I was wondering if following syntax evaluates as I think it does : Cluster.prototype.test_json_availability
I'm trying to decide whether it might make sense to use modernizr.js. Does covering
Does anyone know if there is a way to generate different code in the
Does COUNT(*) have any significant impact for MySQL performance if query already has GROUP
Does anyone have a translate function for x/y positions after rotation in javascript? for
Does anyone know of a free tool, similar to what is built into Visual

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.