Guest User

Untitled

a guest
Oct 16th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. function Foo(x) {
  2. this.x = x;
  3. this.y = 432;
  4. }
  5. Foo.prototype.point = function() {
  6. return 'Foo(' + this.x + ', ' + this.y + ')';
  7. }
  8.  
  9. var myfoo = new Foo(99);
  10. console.log(myfoo.point()); // prints "Foo(99, 432)"
  11.  
  12.  
  13. class Foo {
  14. constructor(x) {
  15. this.x = x;
  16. this.y = 432;
  17. }
  18.  
  19. point() {
  20. return 'Foo(' + this.x + ', ' + this.y + ')';
  21. }
  22. }
  23.  
  24. let myfoo = new Foo(99);
  25. console.log(myfoo.point()); // prints "Foo(99, 432)"
Add Comment
Please, Sign In to add comment