Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const newItem = new Item("book", 'Biography')
- newItem.displayItem() => ReferenceError: Item is not defined
- class Item {
- constructor(name, description) {
- this.name = name
- this.description = description
- }
- displayItem() {
- console.log("item: "+ this.name)
- }
- }
- /////////
- newItem.displayItem() => Cannot read property 'displayItem' of undefined
- class Item {
- constructor(name, description) {
- this.name = name
- this.description = description
- }
- displayItem() {
- console.log("item: "+ this.name)
- }
- }
- const newItem = new Item("book", 'Biography')
Add Comment
Please, Sign In to add comment