Guest User

Untitled

a guest
Apr 5th, 2018
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. /* CLASS */
  2.  
  3. class User {
  4.  
  5. }
  6.  
  7. /* FUNCTIONS / METHOD */
  8. register () {
  9. console.log('User Registered...');
  10. }
  11.  
  12.  
  13. /* CLASS AND METHOD EXAMPLES */
  14. class User {
  15. constructor(username, email, password) {
  16. this.username = username;
  17. this.email = email;
  18. this.password = password;
  19. }
  20.  
  21. static countUsers() {
  22. console.log('There are 50 users');
  23. }
  24.  
  25. register() {
  26. console.log(this.username + ' is Registered')
  27. }
  28. }
  29.  
  30. let John = new User('John', 'John@hotmail.com', '1234'); // Creating new user John
  31.  
  32. John.register(); // Calling register method
  33.  
  34. User.countUsers(); // Calling countUsers method
  35.  
  36. John.register(); // calling method register
Add Comment
Please, Sign In to add comment