<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>自动分号插入 ASI</title> </head> <body> </body> </html>
1 // call 与 apply 2 // 构造形状类 3 function Sharp(name){ 4 this.name = name 5 } 6 Sharp.prototype.area = function(l,w) { 7 console.log(this.l*this.w) 8 } 9 10 function Circle(name){ 11 Sharp.call(this,name) 12 } 13 Circle.prototype.area = function (r) { 14 console.log(Math.PI*r*r) 15 } 16 var c1 = new Circle('圆') 17 c1.name 18 c1.area(5)