Does === exist in jquery
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 the operator exists in javascript. jQuery is just a framework built with javascript so all of the javascript syntax and operators are still there.
Yes, it is part of the JavaScript language. ===
and ==
are the same except that ==
will try to convert the types while ===
will not.
JQuery is a Javascript library. The "==" operator does indeed exist in Javascript. If you want strict equality, you should use the "===" operator.
http://www.webreference.com/js/column26/stricteq.html
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.
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
精彩评论