Timeline for Check if a value is an object in JavaScript
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 31, 2022 at 8:09 | comment | added | Manoj Rana |
if your variable can't have falsy value varName && varName.constructor.name === "Object" if your variable may have falsy value varName != null && varName != undefined && varName.constructor.name === "Object"
|
|
| Oct 28, 2020 at 14:17 | comment | added | Emilio Grisolía | This will fail with undefined too. | |
| Jan 24, 2018 at 14:15 | comment | added | Jankapunkt |
@rounce I am aiming to support older IE versions, why does it not work in IE? Because of the indexOf or because of constructor.name?
|
|
| May 17, 2016 at 14:08 | comment | added | Victor |
null throws an exception Uncaught TypeError: Cannot read property 'constructor' of null(…)
|
|
| Feb 27, 2016 at 23:20 | comment | added | K3---rnc |
Why the string comparison, why not simply item.constructor === Object?
|
|
| Sep 18, 2014 at 19:01 | review | Late answers | |||
| Sep 18, 2014 at 19:02 | |||||
| Sep 18, 2014 at 18:51 | review | First posts | |||
| Sep 18, 2014 at 18:56 | |||||
| Sep 18, 2014 at 18:42 | history | answered | Michal | CC BY-SA 3.0 |