1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!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>
- /*
- 1.call(修改的this,参数1,参数2)
- 2.apply(修改的this,[参数1,参数2])
- 3.bind(修改的this,参数1,参数2)()
-
- */
- // var person = {
- // name:'zs',
- // age: 18,
- // eat: function(){
- // console.log(this)
- // }
- // }
- // person.eat()
- var person2 = {
- name: 'lisi',
- age: 30
- }
- // person.eat.call(person2)
- function xx(x,y){
- console.log(this,x,y)
- }
- xx(1,2)
- xx.call(person2,1,2)
- // xx.apply(person2,[1,2])
- // xx.bind(person2,1,2)()
- </script>
- </body>
- </html>
|