How does the typeof method works in Javascript?
This question already has an answer here:
The first case is equivalent. The ===
performs the same operation as the ==
, except that it does not perform any type conversions . See this answer for more details.
So,
if ( variable === true || variable === false) {
...
}
Will evaluate to true only when variable
is a boolean variable.
As for the inner workings of typeof
, you can read this and, of course, it's manual. Keep in mind that typeof
is a language operator, much like ===
, ==
, or &
. To know exactly how it is implemented and how it knows the variable types, you need to check the code for it.
I never looked at a JavaScript Engine source code, so I don't know where you could look.
链接地址: http://www.djcxy.com/p/19438.html上一篇: 在javascript中比较值