Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var PointPrototype={
- x:0,
- y:0,
- print:function(){
- console.log('x:'+this.x+',y:'+this.y)
- }
- }
- p0=Object.create(PointPrototype,{
- x:{value:5},
- })
- p0.print() //x:5,y:0
- var LinePrototype=Object.assign(PointPrototype,{
- m:0,
- print:function(){
- console.log(this.m?'y='+this.m+"x+"+(this.y-(this.m*this.x)):'y='+(this.y-this.m*this.x))
- }
- })
- l0=Object.create(LinePrototype,{
- y:{value:2},
- m:{value:5}
- });
- l0.print() //y=5x+2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement