SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title></title>
	</head>
	<body>
        <h1>预编译</h1>
        1.找出var定义的值
        2.找出变量声明 function a() {}
        3.按照顺序执行一遍

		<script>
			function test(a, b) {

				console.log(a);  //function a() {}
				console.log(b);  //undefined
				var b = 234;
				console.log(b); //234
				a = 123;
				console.log(a); //123

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

			// var obj = {
			// 	val: 2,
			// 	fun: function() {
			// 		val = 11
			// 		console.log(this)
			// 		this.val = 2 * this.val
			// 		console.log(val)
			// 		console.log(this.val)
			// 	}
			// }

			// var f = obj.fun() //fun: function() {} //11 //4
			// 	var fn = obj.fun 
			// fn() // windows 22 22

			// function fn(a) {
			// 	console.log(a); //function a() {}
			// 	var a = 123;
			// 	console.log(a); //123
			// 	function a() {}
			// 	console.log(a); //123
			// 	var b = function() {}
			// 	console.log(b); //function() {}
			// 	function d() {}
			// }
			// fn(1);


			// function test(a, b) {
			// 	console.log(a); //1
			// 	c = 0;
			// 	var c;
			// 	a = 3;
			// 	b = 2;
			// 	console.log(b); //2
			// 	function b() {}

			// 	function d() {}
			// 	console.log(b);  //2
			// }
			// test(1);

			// function test(a, b) {
			// 	console.log(a); //function a() {}
			// 	console.log(b); //undefined
			// 	var b = 234;
			// 	console.log(b); //234
			// 	a = 123;
			// 	console.log(a); //123

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

			// global = 100;
			// function fn() {
			// 	console.log(global); //undefined
			// 	global = 200;
			// 	console.log(global); //200
			// 	var global = 300;
			// }
			// fn();
			// var global;


			// function bar() {
			// 	return foo;
			// 	foo = 10;

			// 	function foo() {}
			// 	var foo = 11;
			// }
			// console.log(bar()); //function foo() {}


			// function bar() {
			// 	foo = 10;

			// 	function foo() {}
			// 	var foo = 11;
			// 	return foo;
			// };

			// function foo() {
				
			// 	bar.apply(null, arguments,1);
			// }

			// function bar() {
			// 	console.log(arguments);
			// }
			// foo(1, 2, 3, 4, 5);
		</script>
	</body>
</html>