Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class Test {
  2. whatIsMyName(name) {
  3. this.name = name;
  4. }
  5. tellMyName() {
  6. return this.name;
  7. }
  8. }
  9.  
  10. let a = new Test();
  11. a.whatIsMyName("Bob");
  12. a.tellMyName(); // "Bob"
  13.  
  14. class Test {
  15. static whatIsMyName() {
  16. const name = "Bob";
  17. return name;
  18. }
  19. static tellMyName() {
  20. return Test.whatIsMyName();
  21. }
  22. }
  23.  
  24. Test.whatIsMyName(); // "Bob"
  25. Test.whatIsMyName(); // "Bob"
  26. Test.tellMyName(); // "Bob"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement