Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. var PointPrototype={
  2. x:0,
  3. y:0,
  4. print:function(){
  5. console.log('x:'+this.x+',y:'+this.y)
  6. }
  7. }
  8.  
  9. p0=Object.create(PointPrototype,{
  10. x:{value:5},
  11. })
  12.  
  13. p0.print() //x:5,y:0
  14.  
  15. var LinePrototype=Object.assign(PointPrototype,{
  16. m:0,
  17. print:function(){
  18. console.log(this.m?'y='+this.m+"x+"+(this.y-(this.m*this.x)):'y='+(this.y-this.m*this.x))
  19. }
  20. })
  21.  
  22. l0=Object.create(LinePrototype,{
  23. y:{value:2},
  24. m:{value:5}
  25. });
  26.  
  27. l0.print() //y=5x+2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement