123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <ul>
- <li>1</li>
- <li>2</li>
- <li>3</li>
- </ul>
- <script>
- // function fn1(){
- // }
- // var fn = () => {
- // console.log(111)
- // }
- // fn()
- /*
- 箭头函数和普通函数的区别:
- 1.普通函数调用this-> window
- 2.箭头函数 指向声明时的this(父作用域的this)
- 3.箭头函数 不能作为构造函数 不能new 没有prototype
- 4.箭头函数可以使用rest 但是不能使用arguments
- 5.
-
- */
- // var aLi = document.querySelectorAll('li')
- // for (var i = 0; i < aLi.length; i++) {
- // aLi[i].onclick = function(){
- // // setTimeout(function(){
- // // console.log(this)
- // // }.bind(this),100)
- // setTimeout(()=>{
- // console.log(this)
- // },1000)
- // }
- // }
- // var person = {
- // name: 'zs',
- // age: 18,
- // eat: function(){
- // console.log(this)
- // // setTimeout(function(){
- // // console.log(this)
- // // }.bind(this),1000)
- // setTimeout(()=>{
- // console.log(this)
- // },100)
- // }
- // }
- // person.eat()
- /* var person = (name) =>{
- this.name = name
- }
- var p1 = new person('zs')
- console.log(p1) */
- // var p = () => {
- // a = 1
- // }
- // // const aa = new p()
- // // console.log(p)
- // function x(){
- // b = 2
- // }
- // console.log(x)
- // const bb = new x()
- // const fn = ()=>{
- // console.log(arguments)
- // }
- // fn(1,2,3)
- // function fn(x, y) {
- // return x + y
- // }
- // console.log(fn(4, 5))
- var fn = (x, y) => {
- return c = x + y
- console.log(c)
- }
- console.log(fn(1,2))
- </script>
- </body>
- </html>
|