Skip to content

Instantly share code, notes, and snippets.

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

var foo = {
   bar: function() { return this.baz; },
   baz: 1
};
(function(){
    return typeof arguments[0].call(foo);
})(foo.bar);

@iLoosen
Copy link

iLoosen commented Sep 1, 2014

PS:
未定义;

@wsgouwan
Copy link

结果为undefined , 因为 在这里 我们穿进去的参数 foo.bar 仅仅是一个函数 ,而arguments0调用时 并没有指定谁调用他,那么就是window ,但是window.bar并没有被声明或者负值

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