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

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 6.0.7.1 (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
Daniel

Everyone's tags (1)
1 REPLY
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

120
Views
0
Helpful
1
Replies