Linked Questions

-1 votes
3 answers
34k views

if(typeof (document.getElementById("courseId").value!=="undefined") || document.getElementById("courseId").value!==null) { Courseid = document.getElementById("courseId").value; }
Matrix's user avatar
  • 93
-2 votes
1 answer
10k views

I'm working on an Angular 11 project and I'm struggling with checking for null and undefined. I have three strings - equipmentId, roomId and personnelId and a flag (boolean) adresseeChosen. I want the ...
Vasile Verssachen's user avatar
-1 votes
3 answers
896 views

Possible Duplicate: How to check for undefined or null variable in javascript I want to check for an defined variable in javascript. Please see the following few examples and help me which is the ...
Om3ga's user avatar
  • 33.4k
-1 votes
3 answers
1k views

I'm trying to create a personalized welcome message on the homepage, that basically says "welcome [username]" providing the user has registered and their username goes into localStorage. That works ...
Palmer's user avatar
  • 87
0 votes
3 answers
360 views

I have a function: function goError(thing){ console.log(typeof(thing)); //RETURNS A STRING 'UNDEFINED' if(typeof(thing) != undefined){ console.log(thing); //RETURNS UNDEFINED ...
Daft's user avatar
  • 11.1k
2 votes
5 answers
145 views

For detect undefined variable which have been declared in javascript there at least two different ways. var bar; // declared variable if (typeof bar !== "undefined") { // make something with ...
antonjs's user avatar
  • 14.3k
0 votes
3 answers
179 views

I don't understand the difference between these two ways of checking if a variable is undefined: if (typeof res.locals.user.hashnodes === 'undefined') { morphemes = 0; } and if (!res.locals....
Aerodynamika's user avatar
  • 8,614
-2 votes
2 answers
121 views

I was wondering, what's the best way to check if something is null or undefined in JSON arrays or objects in general? For years i've been using if (value !== null && value !== undefined) { /...
sda dsasdsa's user avatar
4154 votes
56 answers
5.9m views

Is there a string.Empty in JavaScript, or is it just a case of checking for ""?
casademora's user avatar
  • 70.1k
3248 votes
49 answers
1.5m views

How do I check if an object property in JavaScript is undefined?
Matt Sheppard's user avatar
2717 votes
33 answers
3.5m views

How do I determine if a variable is undefined or null? My code is as follows: var EmpName = $("div#esd-names div#name").attr('class'); if(EmpName == 'undefined'){ // DO SOMETHING }; <...
sadmicrowave's user avatar
180 votes
6 answers
87k views

The relevant IEEE standard defines a numeric constant NaN (not a number) and prescribes that NaN should compare as not equal to itself. Why is that? All the languages I'm familiar with implement this ...
max's user avatar
  • 52.7k
185 votes
8 answers
526k views

I've come across the following code: function test(data) { if (data != null && data !== undefined) { // some code here } } I'm somewhat new to JavaScript, but, from other ...
afsantos's user avatar
  • 5,206
80 votes
6 answers
261k views

When I write watch handling functions I check newVal param on undefined and null. Why does AngularJS have such a behavior, but doesn't have particular utility method? So there is angular.isUndefined ...
slo2ols's user avatar
  • 1,009
27 votes
8 answers
63k views

I have this code: var sideBar = localStorage.getItem('Sidebar'); I want to check if sideBar is defined and not null in an if statement. I am a bit confused I know there's a: sideBar == undefined and ...
user avatar

15 30 50 per page