Wednesday, August 22, 2012

JavaScript and other language that use losely defined vars

Hey anyone out there that uses JavaScript in a professional environment. I wanted to know the standard when comparing values using == and === operators. I was watching a video the explained that if you compared a sting with a value of \’5\’ and an int with a value of 5 it returns true using the == operator. They then suggested to use the === for everything. I know this is wrong because what if you wanted to compare some value nested in some polymorphic objects with different type defs say one being a student and the other being an instructor the === would always return false.


After much thought I came to the conclusion that it might be best to use === whenever possible and the == when only necessary.


Can you give me some insight on what the rule of thumb is in a professional environment?






Rating: 1 out of 5 based on 3 ratings



The post JavaScript and other language that use losely defined vars appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/javascript-and-other-language-that-use-losely-defined-vars.html

No comments:

Post a Comment