Home How to determine if variable is 'undefined' or 'null'?
Reply: 0

How to determine if variable is 'undefined' or 'null'?

user501
1#
user501 Published in June 20, 2018, 7:20 am

How do I determine if variable is undefined or null? My code is as follows:

var EmpName = $("div#esd-names div#name").attr('class');
if(EmpName == 'undefined'){
  //DO SOMETHING
};
<div id="esd-names">
  <div id="name"></div>
</div>

But if I do this, the JavaScript interpreter halts execution.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.551421 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO