I would like to know which way to check if a variable is null
or undefined
in AngularJS is the best way.
First way:
if(!myVar){...}
Second way:
if(myVar === null || myVar === undefined){...}
Third way:
if(angular.isUndefined(myVar) || myVar === null){...}
I prefere the first one but I want to be sure if it's the best way.
The problem with the last one is that I use an angular's function to test if it's undefined and a native JavaScript way to check if it's null.