1. 程式人生 > >函式分析題

函式分析題

1.
var a = 12
function fn() {  
console.log(a) 
  var a = 45;  
console.log(a)  
}
fn()
2.
function fn() {  
console.log(11)  
function ff() {    
console.log(22)  
}  
ff()
}
fn()
3.
function fn() { 
console.log(5)   fn()  
}
fn()
4.
var a = 123;

function fun() {
alert(a);
}
fun();
5.
var a = 123;

function fun() {
alert(a);
var a = 456;
}
fun();
alert(a);
6.
var a = 123;

function fun(a) {
alert(a);
a = 456;
}
fun();
alert(a);
7.
var a = 123;

function fun(a) {
alert(a);
a = 456;
}
fun(123);
alert(a);
8.
function test(a, b) {
console.log(a);
console.log(b);
var b = 234;
console.log(b);
a = 123;
console.log(a);

function a() {}
var a;
b = 234;
var b = function() {}
console.log(a);
console.log(b);
}
test(1);
9.
function fn(a) {
console.log(a);
var a = 123;
console.log(a);

function a() {}
console.log(a);
var b = function() {}
console.log(b);

function d() {}
}
fn(1);
10.
function fn() {  
console.log(12)
}
var as = fn() console.log(as) 11.
function fn() {  
console.log(12)   return 45;  
console.log(456)  
}
12.
var a = 12; 
function fn() {  
console.log(a)   return 4;  
var a = 45;
}
13.
var a = 100; 
function testResult() {  
var b = 2 * a  
var a = 200  
var c = a / 2   alert(b)   alert(c)
}
testResult()