Cisco Support Community
Showing results for 
Search instead for 
Did you mean: 

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Proper use of undefined

Proper use of undefined

Leslie:  I bet you have an answer for this one...

I am on version (1961)

My goal is to check and see if a dictionary is not present because its permission was accidently set to NONE.

When I use this ISF nothing happens...
   if (serviceForm.TRA_INSTRUCTION == undefined)  
   alert('Service form is missing the Instructions dictionary')

but if I change it to a double negative it works
   if (!serviceForm.TRA_INSTRUCTION != undefined)
   alert('Service form is missing the Instructions dictionary')

Is this the way that the use of "undefined" was intended - or did I miss something in class.   Like I said, the double negative works fine,  But I would think that "equal to undefined" would work too.

Thank you

Everyone's tags (1)
New Member

Proper use of undefined

What you're trying to do is figure out if the dictionary object is defined. The more technically correct expression to do this would be to compare the typeof the object (ie, typeof serviceForm.TRA_INSTRUCTION) to "undefined" -- that would work with an equivalence expression. A longer discussion of, or reference to, object usage in JavaScript should ensue, but it's Saturday. (I think your original attempt is a little like comparing values in a relational database to null -- nothing is ever equal