-
1.if ('m' in window) {
2. var m = m && 12;
3.}
4.console.log(m);
1.let n = 10;
2.if (!('n' in window)) {
3. let n = n + 30;
4.}
5.console.log(n);
复制代码
-
1.let n = 10,
2. m = 20;
3.~function (n, m) {
4. let arg = arguments;
5. arg[0] = n || 100;
6. arg[1] = m || 200;
7. console.log(n, m);
8.}(m);
9.console.log(n, m);
复制代码
-
1.let n = 10,
2. m = 20;
3.~function (n, m) {
4. let arg = arguments;
5. arg[0] = n || 100;
6. arg[1] = m || 200;
7. console.log(n, m);
8.}(m);
9.console.log(n, m);
复制代码
-
1.let ary = [12, 23, 34, 45];
2.(function (ary) {
3. ary.pop();
4. ary = ary.slice(0);
5. ary.shift();
6. console.log(ary);
7.})(ary);
8.console.log(ary);
复制代码
-
1.let n = 10,
2. obj = {n: 20};
3.let fn = obj.fn = (function () {
4. this.n++;
5. n++;
6. return function (m) {
7. n += 10 + (++m);
8. this.n += n;
9. console.log(n);
10. }
11.})(obj.n);
12.fn(10);
13.obj.fn(10);
14.console.log(n, obj.n);
复制代码
-
1.let a = {n: 4};
2.let b = a;
3.b.x = a = {n: 10};
4.console.log(a.x);
5.console.log(b.x);
复制代码
-
1.function C1(name) {
2. if (name) this.name = name;
3.}
4.function C2(name) {
5. this.name = name;
6.}
7.function C3(name) {
8. this.name = name || 'join';
9.}
10.C1.prototype.name = 'Tom';
11.C2.prototype.name = 'Tom';
12.C3.prototype.name = 'Tom';
13.alert(new C1().name + new C2().name + new C3().name);
复制代码
- 忽略报错对后面代码的影响
1.let m = 20;
2.let Fn = function (n, m) {
3. this.n = n;
4. this.aa = function () {
5. console.log(this.n + (++m));
6. }
7.};
8.Fn.prototype.bb = function () {
9. console.log(this.n + m);
10.};
11.let f1 = new Fn(10, 20);
12.Fn.prototype = {
13. cc: function () {
14. console.log(this.n + m);
15. }
16.};
17.let f2 = new Fn(30);
18.console.log(f1.constructor === f2.constructor);
19.f1.aa();
20.f1.bb();
21.f1.cc();
22.f2.bb();
23.f2.cc();
24.f2.__proto__.cc();
复制代码
-
console.log(a);
var a=12;
function fn(){
console.log(a);
var a=13;
}
fn();
console.log(a);
输出的三次分别是多少
A、undefined 12 13 B、undefined undefined 12
C、undefined undefined 13 D、有程序报错
复制代码
-
2、console.log(a);
var a=12;
function fn(){
console.log(a);
a=13;
}
fn();
console.log(a);
A、undefined 12 13 B、undefined undefined 12
C、undefined undefined 13 D、有程序报错
复制代码
-
3、console.log(a);
a=12;
function fn(){
console.log(a);
a=13;
}
fn();
console.log(a); 输出的三次分别是多少
A、undefined 12 13 B、undefined undefined 12
C、undefined undefined 13 D、有程序报错
复制代码
-
4、var foo=1;
function bar(){
if(!foo){
var foo=10;
}
console.log(foo);
}
bar(); 输出的结果是多少
A、1 B、10 C、undefined D、报错
复制代码
-
5、var n=0;
function a(){
var n=10;
function b(){
n++;
alert(n);
}
b();
return b;
}
var c=a();
c();
alert(n);
弹出三次的结果分别是什么?
A、1 1 1 B、11 11 0 C、11 12 0 D、11 12 12
复制代码
-
6、var a=10,b=11,c=12;
function test(a){
a=1;var b=2;c=3;
}
test(10);
alert(a); alert(b); alert(c); 弹出的三个值分别是多少?
A、1 11 3 B、10 11 12 C、1 2 3 D、10 11 3
复制代码
-
if(!("a" in window)){
var a=1;
}
alert(a);
弹出的a的值是?
A、1 B、undefined C、报错 D、以上答案都不对
复制代码
-
var a=4;
function b(x,y,a) {
alert(a);
arguments[2]=10;
alert(a);
}
a=b(1,2,3); alert(a); 三次弹出的结果是
A、3 3 4 B、3 10 4 C、3 10 10 D、3 10 undefined
复制代码
-
var foo='hello';
(function(foo){
console.log(foo);
var foo=foo||'world';
console.log(foo);
})(foo);
console.log(foo); 三次分别输出什么?
A、hello hello hello B、undefined world hello C、hello world world D、以上答案都不正确
复制代码
-
var a=9;
function fn(){
a=0;
return function(b){ return b+a++; }
}
var f=fn()
var m=f(5);alert(m);
var n=fn()(5);alert(n);
var x=f(5);alert(x);
alert(a); 弹出的四次结果?
A、6 6 7 2 B、5 6 7 3 C、5 5 6 3 D、以上答案都不正确
复制代码