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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:16:23+00:00 2026-06-17T07:16:23+00:00

I am using Object.prototype.toString.call to identify variable types. I would expect the following behavior:

  • 0

I am using Object.prototype.toString.call to identify variable types. I would expect the following behavior:

Object.prototype.toString.call({}) => [object Object]
Object.prototype.toString.call([]) => [object Array]
Object.prototype.toString.call(undefined) => [object Undefined]
Object.prototype.toString.call(null) => [object Null]

This usually works fine, but I am currently faced with a situation (in Internet Explorer) where both Object.prototype.toString.call(undefined) and Object.prototype.toString.call(null) return [object Object], and I don’t understand why. I tried to replicate it on jsfiddle.net but couldn’t, so I am assuming I am in a specific quirk mode.

My questions:

  • Is this a known “behavior”, and when does this happen?
  • is there a more reliable way to check object types (I need to support IE7+)?
  • 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-17T07:16:25+00:00Added an answer on June 17, 2026 at 7:16 am

    ECMAScript5 specification states in §15.2.4.2 about the Object.prototype.toString method:

    When the toString method is called, the following steps are taken:

    1. If the this value is undefined, return "[object Undefined]".
    2. If the this value is null, return "[object Null]".
    3. Let O be the result of calling ToObject passing the this value as the argument.
    4. Let class be the value of the [[Class]] internal property of O.
    5. Return the String value that is the result of concatenating the three Strings "[object ", class, and "]".

    The problem you are facing is that IE7 and 8 follow the older ECMAScript3 standard, which states in the same section that

    When the toString method is called, the following steps are taken:

    1. Get the [[Class]] property of this object.
    2. Compute a string value by concatenating the three strings "[object ", Result(1), and "]".
    3. Return Result(2).

    That is, in older versions of IE, the method will not return [object Undefined] or [object Null] unless they are constructed from functions named Undefined or Null.

    You can check for types more reliably using the following methods:

    typeof x === "object"    // x is any sort of object
    typeof x === "undefined" // x is undefined
    x instanceof Array       // x is an array
    x === null               // x is null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using an array in my object prototype which basically has add, remove, search
Just wonder. I have extended javascript Array object using its prototype as follows: <html>
null and undefined don't have a toString or valueOf method. Afaik using String calls
I've read that using Object.prototype to attach functions to custom JavaScript objects is more
What is the difference between the following two snippets of code: using (Object o
I'm trying to add a toBool() method inside the Object object using prototype... something
I am having a problem with using an object as a prototype for some
using prototype method we can create new methods... like... Object.prototype.newMethod=function(){ // do something }
I'm just now getting into instantiating JavaScript object literals using a prototype constructor, but
I'm trying to override methods of an object but still call the prototype's original

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.