Skip to content

Instantly share code, notes, and snippets.

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

看到with顿时一阵菊紧,迅速查证了一番,with是js保留的关键字,目的是减少键盘输入;
可以这么看with(function(x, undefined){})就是里面的这个函数对象,然后输出函数对象的长度,也就是参数的个数;
不建议使用这个关键字,可能会坑自己

@replace5
Copy link

var fn = function(x, undefined){};
fn.length;

@rambo-panda
Copy link

求函数的形参个数
极力不推荐with啊 还不容定义一个变量呢

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