Skip to content

Instantly share code, notes, and snippets.

@jikeytang
Created August 13, 2014 13:21
Show Gist options
  • Save jikeytang/4a506320202dec2fe9c1 to your computer and use it in GitHub Desktop.
Save jikeytang/4a506320202dec2fe9c1 to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140814-题目1
(function(x){
delete x; return x;
})(1);
求出以上表达式的值,为什么?
PS:
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。
```javascript
// you code
```
2. 粘贴代码时请使用shift+tab,缩进前面的空白。
@rambo-panda
Copy link

window.x=100;
(function(x){
    delete window.x; return x;
})(1);   // 初学的时候 被这个整过

@wsgouwan
Copy link

(function(x){
        //  相当于  var x = 1 ;
        //  delete x ; 因为声明的变量不会被删除,这个在非严格模式中无效
        //  return x ; 值仍然为1
    })(1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment