-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
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
"JSPatch 实现原理详解"这篇文章最后关于js中false以及Boolean对象的说明有误。 #351
Comments
已在原文加链接 |
'use strict';
Object.prototype.c = function(){console.log(this === false)};
false.c() //output true |
有没有加
从输出来看,没有 而加上 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
原文链接:https://github.com/bang590/JSPatch/wiki/JSPatch-%E5%AE%9E%E7%8E%B0%E5%8E%9F%E7%90%86%E8%AF%A6%E8%A7%A3
原文描述:
“题外话,神奇的 JS 里 false 的 this 竟然不再是原来的 false,而是另一个 Boolean 对象,太特殊了:
Object.prototype.c = function(){console.log(this === false)};
false.c() //output false”
===比较时,this是临时包装对象,false是原始值,返回false是应该的。
若写成如下语句,返回为true。
The text was updated successfully, but these errors were encountered: