UNPKG

190819-utils

Version:

尚硅谷大前端自定义工具函数库

41 lines (34 loc) 818 B
<!DOCTYPE html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <script type="text/javascript"> function Cat(name,age,color){ this.name = name this.age = age this.color = color } function Person(name,age){ this.name = name this.age = age } Cat.prototype.eat = function (){ console.log('我喜欢吃🐟'); } let cat1 = new Cat('奶油',2,'蓝'); let per1 = new Person('lianpw',28) function fn(name){ console.log(this); console.log('i love you',name); } window.fn() // cat1.fn() fn.call(cat1,'yangmi') cat1.eat() // cat1.eat.apply(per1) </script> </body> </html>