Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. > class User {
  2. ...
  3. ... constructor(name) {
  4. ... this.name = name;
  5. ... }
  6. ...
  7. ... sayHi() {
  8. ... alert(this.name);
  9. ... }
  10. ...
  11. ... }
  12. undefined
  13. > x=User("a")
  14. TypeError: Class constructor User cannot be invoked without 'new'
  15. > x=new User("a")
  16. User { name: 'a' }
  17. > x
  18. User { name: 'a' }
  19. > x.Name='b'
  20. 'b'
  21. > x
  22. User { name: 'a', Name: 'b' }
  23. >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement