I'm aware of the === operator in PHP which connotes not only value equality, but type matching also i.e.
if (20 === "20") //false
Is there something similar in javascript if I'm using jquery? Examples code could help too.
Thanks
I'm aware of the === operator in PHP which connotes not only value equality, but type matching also i.e.
if (20 === "20") //false
Is there something similar in javascript if I'm using jquery? Examples code could help too.
Thanks
Yes, it is part of the JavaScript language. === and == are the same except that == will try to convert the types while === will not.
The JavaScript behavior of === is very similar to php - check for equality and same type.
This is not jQuery by the way - jQuery is a JavaScript framework. Basically, it's a group for JavaScript functions. It isn't the language.
Yes the operator exists in javascript. jQuery is just a framework built with javascript so all of the javascript syntax and operators are still there.
JQuery is a Javascript library. The "==" operator does indeed exist in Javascript. If you want strict equality, you should use the "===" operator.
According to an article on Net Tuts by jeffrey way titled "24 JavaScript Best Practices" that recommends:
"JavaScript utilizes two different kinds of equality operators: === | !== and == | != It is considered best practice to always use the former set when comparing."
Obviously the same rule applies when using jQuery.
see the article here: 24 JavaScript Best Practices