日期:2014-05-16 浏览次数:20470 次
function test(){
console.log(i);// undefined
//console.log(j); // ReferenceError: j is not defined
var i="a string";
console.log(i);// "a string"
fun1();// "this is fun1"
fun2();// ReferenceError: fun2 is not defined
function fun1(){
console.log("this is fun1");
}
}
test();
function test() {
bar(); // "bar will run!"
foo(); // TypeError "foo is not a function"
function bar() { // function declaration, given the name 'bar'
console.log("bar will run!");
}
var foo = function () { // function expression assigned to local variable 'foo'
console.log("this won't run!");
}
}
test();