Questions tagged «typeof»

Typeof(或者typeof或TypeOf)是由几种编程语言提供的运算符,用于确定给定变量的数据类型。当构造需要接受多种数据类型但可能需要根据提供的数据类型采取不同操作的程序部分时,这很有用。

2
为什么undefined在JavaScript中不可写?
根据MDN的文档undefined: 在现代浏览器(JavaScript 1.8.5 / Firefox 4+)中,根据ECMAScript 5规范,undefined是不可配置的,不可写的属性。即使不是这种情况,也请避免覆盖它。 undefined的属性属性之一是不可写的。 但是,如果我这样做: var undefined = 'hello'; var test = undefined; console.log(typeof test); //string 运行代码段隐藏结果展开摘要 这是否意味着我可以覆盖的值undefined?如果有人这样做会怎样?JavaScript是否应该对此发出警告?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.