// var a = 10; ---> window.a = 10;
/*
预编译:
1.创建AO对象
2.找形参和变量声明,将变量和形参名作为AO属性名,值为undefined
3.将实参和形参统一
4.在函数体里面找函数声明,值赋予函数体
*/
/*
window的预编译
window === GO
1.生成一个GO对象 Global Object
2.找形参和变量声明,将变量和形参名作为AO属性名,值为undefined
3.在函数体里面找函数声明,值赋予函数体
*/
//例题1:
/*预编译
1小时--> 1小时7分结束*/
// function fn(a) {
// console.log(a);
// //a = function a () {}
// var a = 123;
// console.log(a);
// //a = 123
// function a() {};
// console.log(a);
// //a = 123
// var b = function () {};
// console.log(b);
// //b = function () {}
// function d() {};
// console.log(d);
// //d = funxtion d() {}
// }
// fn(1);
//例题2:[1:08:21 --> 1:11:26]
// function test(a, b) {
// document.write(a);
// c = 0;
// var c;
// a = 3;
// b = 2;
// document.write(b);
// function b() {};
// function d() {};
// document.write(b);
// }
// test(1);
//例题3:[]
// 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();
/*例题4
//时间 1:21:20-->1:22:30
暗示全局变量impiy global
function test () {
var a = b = 123;
console.log(window.b)
//b = 123;
console.log(window.a)
//undefined
}
test()
*/
//例题5
//时间1:24:01-->1:26:40
// console.log(test);
// test = function test(test) {
// console.log(test);
// var test = 234;
// console.log(test);
// function test() {}
// };
// function test(test) {
// console.log(test);
// test = function test() {};
// var test = 234;
// console.log(test);
// function test() {}
// }
// test(1)
// var test = 123;
//例题6
//时间1:30:08 -->1:32:11
// global = 100;
// function fn() {
// console.log(global);
//
// global = 200;
// console.log(global);
//
// var global = 300;
// }
// fn();
// var global;
//例题7
//时间1:33:44-->1:38:37
// function test () {
// console.log(b);
// if(a) {
// var b = 100;
// }
// console.log(b)
// c = 234;
// console.log(c);
// }
// var a;
// test();
// a = 10;
// console.log(c);
//例题1 [00:53 -->]
// function bar() {
// return foo;
// foo = 10;
// function foo() {
// //body...
// }
// var foo = 11;
// }
// console.log(bar());
// //例题2
// console.log(bar());
// function bar() {
// foo = 10;
// function foo() {
// //body...
// }
// var foo = 11;
// return foo;
// }
预编译
最新推荐文章于 2025-01-12 22:37:38 发布