简体   繁体   English

你应该为变量x分配什么JavaScript值,以便typeof x = = = x是真的?

[英]What JavaScript value should you assign to a variable x so that typeof x = = = x would be true?

I've tried assigning different data types such as boolean, numbers, strings, objects, nulls, etc, but keep getting false returned. 我已经尝试分配不同的数据类型,如布尔值,数字,字符串,对象,空值等,但不断返回false。 Any ideas? 有任何想法吗?

The typeof operator always returns a string value. typeof运算符始终返回字符串值。 As such, your original value must be a string. 因此,您的原始值必须是字符串。 The result of typeof for a string is "string" , and so: 字符串的typeof结果是"string" ,因此:

x = "string"
typeof x === x // true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM