12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <div id="box">hello world</div>
- <script>
- // function foo(){
- // console.log("hello");
- // }
- // let fn = function(){
- // console.log("hello");
- // }
- // // 箭头函数
- // let fn2 = () => {};
- // let fn = (a) => {
- // console.log(a);
- // console.log("hello world");
- // }
- // fn(1);
- // arguments 是一个类数组对象
- // 里面容纳是所有的参数
- // function fn(){
- // console.log(arguments)
- // console.log(arguments[0]);
- // console.log(arguments[1]);
- // }
- // fn(1,'a');
- // // 箭头函数 没有 arguments 这个对象
- // let fn = (...arg) => {
- // // console.log(arguments);
- // console.log(arg);
- // }
- // fn(1,"a");
- // 箭头函数 没有 this这个对象
- let oBox = document.querySelector("#box");
- // oBox.onclick = function(){
- // console.log(this);
- // }
- // oBox.onclick = () => {
- // console.log(this);
- // }
- console.log(this);
-
- </script>
- </body>
- </html>
|