Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > class User {
- ...
- ... constructor(name) {
- ... this.name = name;
- ... }
- ...
- ... sayHi() {
- ... alert(this.name);
- ... }
- ...
- ... }
- undefined
- > x=User("a")
- TypeError: Class constructor User cannot be invoked without 'new'
- > x=new User("a")
- User { name: 'a' }
- > x
- User { name: 'a' }
- > x.Name='b'
- 'b'
- > x
- User { name: 'a', Name: 'b' }
- >
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement