12345678910111213141516171819202122232425262728 |
- <!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>
- <script src="./src/bind.js"></script>
- <script>
- function add (a,b){
- console.log(this)
- return a + b + this.c
- }
- let obj = {
- c: 5
- }
- window.c = 6
- //两种
- let fn = bind(add,obj,1,2)
- console.log(fn())
- let fn2 = bind(add,obj)
- console.log(fn2(1,2))
- </script>
- </body>
- </html>
|