在 英语 中使用 Typeof 的示例及其翻译为 中文
{-}
-
Political
-
Ecclesiastic
-
Programming
What's the typeof null?
Typeof operator, every other use of it should be avoided.
As an operator: typeof x.
The typeof operator makes the distinction between the two values:.
The result of typeof null is"object".
The typeof operator can help you to find the type of your variable.
Buying the right typeof olive oil is crucial.
The more preciseway to check for undefined is to use typeof:.
Buying the right typeof olive oil is crucial.
Typeof will always return"object" for native non callable objects.
Be careful when using typeof, instanceof and constructor.
The typeof operator returns the type for a value, with two exceptions:.
So, even though null is not an object, typeof null returns'object'.
This typeof collapse is not rare, but its magnitude shocked scientists.
For predefined objects, the typeof operator returns results as follows:.
The other operators shown all operated on two values, but typeof takes only.
For a number or string, the typeof operator returns the following results:.
The other operators shown all operated on two values, but typeof takes only one.
The typeof operator can be used to find out what type of data a variable or operand contains.
It is an officially recognized error in typeof, kept for compatibility.
One example is the typeof operator, which produces a string value naming the type of the value you give it.
IsNaN(), as defined in ECMAScript 2015, or you can use typeof to determine if the value is Not-A-Number.
In JavaScript, it is very important totest the type of parameters sent to your functions(using the typeof keyword).
For example, when you use typeof you know it returns a string, so there's no reason to use strict equality.
The switch-type-case statement is a kind of pattern matching on the type andworks similar to an instanceof or typeof in Java or JavaScript.
Typeof null returns a value of"object", as the special value null is considered to be an empty object reference.
You will notice that weare using a special operator called typeof- this returns the data type of the variable you pass into it.