We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
1、
var a = 1; if(true){ console.log(a); let a = 2; }
由于let的创建,所以这里的a应该是报错
2、
(function() { var a = b = 3; })(); console.log(typeof a === 'undefined'); console.log(typeof b === 'undefined');
typeof 报错不会抛出而是等于undefined
3、
function f(){ return f; } console.log(new f() instanceof f);
当new的构造函数返回值是函数的时候,也是同样返回函数,而不是只有对象的时候才返回对象
4、
console.log(1 + -"1" + "2"); console.log( "A" - "B" + "2"); console.log( "A" - "B" + 2);
当用-'1' === -1,所以是'02'。'A' - 'B'则是NaN。NaN + 任何数字 === NaN
5、
var x = 1; if(function f(){}){ x += typeof f; } console.log(x);
(function f(){})的f在括号中并不会函数声明提升。所以f访问不到而typeoof f变成了undefined
6、
Object.prototype.bar = 1; var foo = { goo: undefined }; console.log(foo.bar); console.log('bar' in foo); console.log(foo.hasOwnProperty('bar')); console.log(foo.hasOwnProperty('goo'));
in会去查找原型链上的属性
7、
function foo1() { return { bar: "hello" }; } function foo2() { return { bar: "hello" }; } console.log(foo1()); console.log(foo2());
当换行后,会自动的添加;号,变成return;
8、
console.log(c); var c; function c(a) { console.log(a); var a = 3; } c(2);
变量提升也有优先级, 函数声明 > arguments > 变量声明
The text was updated successfully, but these errors were encountered:
No branches or pull requests
1、
由于let的创建,所以这里的a应该是报错
2、
typeof 报错不会抛出而是等于undefined
3、
当new的构造函数返回值是函数的时候,也是同样返回函数,而不是只有对象的时候才返回对象
4、
当用-'1' === -1,所以是'02'。'A' - 'B'则是NaN。NaN + 任何数字 === NaN
5、
(function f(){})的f在括号中并不会函数声明提升。所以f访问不到而typeoof f变成了undefined
6、
in会去查找原型链上的属性
7、
当换行后,会自动的添加;号,变成return;
8、
变量提升也有优先级, 函数声明 > arguments > 变量声明
The text was updated successfully, but these errors were encountered: