Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-05-2005, 01:09 PM
Intermediate Member
 
Posts: 22
Default Small question about JavaScript operators in DWT code

Hi! Like everybody else I'm very excited about your product and have been going over the code, mostly focusing on DWT at first. I've noticed a couple places where there's a JavaScript operator that I've not seen before. For example:

AjxEventMgr.js:
...
59: if (retVal === false)
...

AjxVector.js:
...
34: if (compress !== true)
...

Are those equivalent to "==" and "!=" respectively? If not, how are they different? If so, why use them instead of "==" and "!="?
Reply With Quote
  #2 (permalink)  
Old 10-05-2005, 02:28 PM
Zimbra Employee
 
Posts: 4,792
Default

The === and !== are identity compares (ie check that things are identical without tye conversion) Some more detail below.






From: http://www.crockford.com/javascript/lint.html



The == and != operators do type coercion before comparing. This is bad because it causes '' == 0 to be true. This can mask type errors.

When comparing to any of the following values, use the === or !== operators, which do not do type coercion.

0 '' undefined null false true
If you want the type coercion, then use the short form. Instead of
(foo != 0)
just say
(foo)
and instead of
(foo == 0)
say
(!foo)
Reply With Quote
  #3 (permalink)  
Old 10-06-2005, 09:43 PM
Junior Member
 
Posts: 7
Default

Check out crockford.com and see his jslint utility to get used to using this operator in your own code. It only took me a couple of times of running my files thru it and I learned the crockford way..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.