javascript - Check that value is object literal? -


i have value , want know if it's iteratable object literal, before iterate it.

how do that?

this should you:

if( object.prototype.tostring.call( someobject ) === '[object object]' ) {     // iteration } 

from ecmascript 5 section 8.6.2 if you're interested:

the value of [[class]] internal property defined specification every kind of built-in object. value of [[class]] internal property of host object may string value except 1 of "arguments", "array", "boolean", "date", "error", "function", "json", "math", "number", "object", "regexp", , "string". value of [[class]] internal property used internally distinguish different kinds of objects. note specification not provide means program access value except through object.prototype.tostring (see 15.2.4.2).


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -