We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object.prototype.yideng = "京程一灯"; var a = 123; a.b = 456; console.log(a.yideng); console.log(a.b)
// 写出执行结果,并解释原因
The text was updated successfully, but these errors were encountered:
每日一题会在下午四点在交流群集中讨论,五点 Github、交流群同步更新答案
Sorry, something went wrong.
console.log(a.yideng); // 京程一灯 console.log(a.b) ; //undefined
var a // 声明提升 Object.prototype.yideng = "京程一灯"; // 向对象添加属性,此时a对象身上有此属性 a = 123; //赋值,a为数字类型 a.b = 456; // 数字类型无法这样赋值,所以打印undefined
结果: console.log(a.yideng); // 京程一灯 console.log(a.b) ; //undefined
解析: var 定义赋值 a 的时候, a 的变量提升成为了 Number类型;Number本身就是一个对象,可以继承 Object 的属性,因此 a.proto 是存在 yideng 这个键的;a 本身作为 Number 类型的值,是不可以设置 键的,所以 a.b 是不存在的
No branches or pull requests
// 写出执行结果,并解释原因
The text was updated successfully, but these errors were encountered: