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
- the variable defined
- its value object
- 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
Post a Comment