1. //变量提升 a
  2. console.log(a);//undefined
  3. if(1==2){//不进判断条件
  4. var a=12;
  5. }
  6. console.log(a);//undefined
console.log(fn);//变量提升//undefined
//EC(G)
//    VO(G)/GO
//        fn---xx001
// 块级私有上下文
//EC(Block)
//    fn====>xx001
if(1==2){//不执行
   function fn(){
       console.log(1)
   }
}
console.log(fn); //undefined
//=========
//EC(G)
//  VO(G)/GO
//      a======>12
//      b======>13
//      c=======>14
//      fn====>0X001堆{scope:{EC(G)},代码字符串,name:fn,length:1}
//  
var a = 12, b = 13, c = 14; //C=20
function fn(a) {
    console.log(a, b, c);//12{私有变量} undefined 14{全局变量}
    var b = c = a = 20;//a=20,c=20,var b=20
    console.log(a, b, c);//20 20 20 
}//此步略过
fn(a);
//EC(fn)
//  scope<EC(fn),EC(G)>
//  AO
//     a=12=>20
//     b=>20
//  
console.log(a, b, c); //12 13 20
console.log(fn)  //函数本身
function fn(){   
    console.log(1)
}
var fn=2;  
concole.log(fn)//2
var ary=[12,13];
function fn(ary){
   console.log(ary);
   ary[0]=100;
   ary=[100];
   ary[0]=0;
   console.log(ary);
}
fn(ary);
console.log(ary);

下图答案

//EC(G)
//    VO(G)/GO
//        ary===>xx000
//      fn===>xx001 [[scope]]:EC(G)
//  变量提升
//    var ary,fn
//    x000堆=>{0:12,1:13}
var ary=[12,13];//[100,13]
function fn(ary){
   console.log(ary);//[12,13]
   ary[0]=100;
   ary=[100];
   ary[0]=0;
   console.log(ary);//[0]
}//此步略过
fn(ary);
//EC(FN)
//    作用域链:scope<EC(FN),EC(G)>
//    形参赋值:ary
//    变量提升:-
//    AO(FN)
//        ary===>xx001=>xx002[0]
console.log(ary);//[100,13]

1、

console.log(a);//undefined
var a=12;
function fn(){
    console.log(a);//undefined
    var a=13;
}
fn();
console.log(a);//12

//选择B
// A、undefined 12、13
// B、undefined undefined、12    
// C、undefined undefined、13
// D、有程序报错

2、

console.log(a);//undefined
var a=12;//13
function fn(){
    console.log(a);//12
     a=13;
}
fn();
console.log(a);//13

//选择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);

//选择D
// A、undefined 12、13
// B、undefined undefined、12
// C、undefined undefined、13
// D、有程序报错

4、

var foo=1;
function bar(){
  if(!foo){=>!undefined true
    var foo=10;
  }
  console.log(foo);
}
bar();//10

//选择B
A 1
B 10
C undefined
D 报错

5

var n=0;
function a(){
    var n=10;
    function b(){
        n++;
        console.log(n);//11
    }
    b();
    return b;
}
var c=a();
c();//12
console.log(n);//0
/*
 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 text(a){
  a=1;
  var b=2;
  c=3;

}
text(10);
console.log(a);//10
console.log(b);//11
console.log(c);//3

A 1 11 3
B 10 11 12
C 1 2 3
D 10 11 3

7

//变量提升
if(!("a" in window)){
 var a=1;

}
console.log(a); //undefined
A undefined
B 1
C 报错
D 以上答案都不对

8

var a=4;
function b(x,y,a){
  console.log(a);//3
  arguments[2]=10;
  console.log(a);//10
}
a=b(1,2,3);
console.log(a)//undefined
A、3  3  4   
B、3  10  4   
C、3  10  10   
D、3  10  undefined

9

var foo="hello";
//EC(AN)
//    foo===>"hello"
(function(foo){
  console.log(foo);//"hello"
  var foo=foo||"word";//hello
  console.log(foo);
})(foo);
console.log(foo);//hello

A hello hello hello
B undefined world hello
c hello world world
D 以上答案都不正确

逻辑与&& 和逻辑或

1、条件判断中使用
2、赋值

var a=1||2  如果第一个值是真,那a的值就是第一个,如果第一个值为假,把第二个值赋值给它
var b=1&&2  如果第一个值的真,那就把第二个值赋值给b,如果第一个值是假的就把第一个值赋值给它

10、

var a=9;
function fn(){
  a=0;
  return function(b){
     return b+a++;
  }
}
var f=fn();
console.log(f(5));//5
console.log(fn()(5));//5
console.log(f(5));//6
console.log(a);//2

11、
var ary=[1,2,3,4];
function fn(ary){
   ary[0]=0;
   ary=[0];
   ary[0]=100;
   return ary;
}
var res=fn(ary);
console.log(ary);//[0,1,3,4]
console.log(res);//[100]

12、

function fn(i){
   return function (n){
      console.log(n+(++i));
   }
}
var f=fn(10);
f(20);//31
fn(20)(40);//61
fn(30)(50);//81
f(30);//42

13、

var i=10;//11=>12=>13
function fn(){
   return function(n){
      console.log(n+(++i));
   }
}
var f=fn();
f(20);//20+(++10) 31
fn()(20);//20+(++11) 32
fn()(30);//30+(++12) 43
f(30);//30+(++13) 44