arrays - JavaScript: what does Object(variable)? -


i ran boolean test variable === object(variable) couldn't find describes it.

is testing variable same object(variable) , object(variable) cast variable object? or else?

if matches loop for (var key in variable) , uses key , variable[key] parameters function. if fails uses variable is.

it checks that

  1. the variable defined
  2. its value object
  3. its value isn't null (be careful: typeof null "object")

this simplest way check these 3 conditions , looks reasonable test run before loop on keys in polymorphic function.

another 1 have been typeof variable === "object" && variable.

from the mdn:

the object constructor creates object wrapper given value. if value null or undefined, create , return empty object, otherwise, return object of type corresponds given value. if value object already, return value.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -