This question already has an answer here:
I want to know whether a object is null or undefined so I use the following code:
if(obj==='undefined'||obj===null)
But it doesn't seem to work. Is there similar python type command to get the type of obj in node.js shell? Thanks!
typeof
:typeof(foo)
--> "undefined" – Ashwini Chaudhary Jun 13 '13 at 8:50obj==='undefined'
assumes thatobj
is a string with the value ofundefined
. – DarthJDG Jun 13 '13 at 8:55isNull
andisUndefined
in your case), but nothing can substitute learning Javascript of course :). – kapa Jun 13 '13 at 9:07type
, you should be usingisinstance
– jamylak Jun 13 '13 at 9:34