4 ms·
The best part of it: if (typeof my_var !== "undefined" && my_var !== null) { // you idiots put Rasmus Lerdorf to shame }
by nakkiel 13y ago
The best part of it:
if (typeof my_var !== "undefined" && my_var !== null) {
// you idiots put Rasmus Lerdorf to shame
}
- Touche 13y agoNo one does that any more. if(my_var != null) { }
- snarkyturtle 13y agoOr they just use lodash/underscore which takes care of it for you.
- Touche 13y agoUsing a library to avoid typing !=null seems like overkill.
- snarkyturtle 13y agoIt's more for handling all those js quirks with equality, though yeah if it's your var, you'll probably be fine with != null (though jshint probably won't like it)