<script type="text/javascript">
function foo() {
if( this=== window) {
console.log(1);
}
}
foo.boo=function() {
if( this=== foo) {
console.log(2);
}
if( this=== window) {
console.log(3);
}
};
foo();
foo.boo();
foo.boo.apply(window);
</script>
function foo() {
if( this=== window) {
console.log(1);
}
}
foo.boo=function() {
if( this=== foo) {
console.log(2);
}
if( this=== window) {
console.log(3);
}
};
foo();
foo.boo();
foo.boo.apply(window);
</script>
本文深入探讨了JavaScript中函数内部的作用域及原型链机制,通过具体实例展示了如何利用这些特性优化代码结构与性能。

被折叠的 条评论
为什么被折叠?



