Guest User

Untitled

a guest
Dec 17th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. const newItem = new Item("book", 'Biography')
  2.  
  3. newItem.displayItem() => ReferenceError: Item is not defined
  4.  
  5. class Item {
  6. constructor(name, description) {
  7. this.name = name
  8. this.description = description
  9. }
  10.  
  11. displayItem() {
  12. console.log("item: "+ this.name)
  13. }
  14. }
  15.  
  16. /////////
  17.  
  18. newItem.displayItem() => Cannot read property 'displayItem' of undefined
  19.  
  20. class Item {
  21. constructor(name, description) {
  22. this.name = name
  23. this.description = description
  24. }
  25.  
  26. displayItem() {
  27. console.log("item: "+ this.name)
  28. }
  29. }
  30.  
  31. const newItem = new Item("book", 'Biography')
Add Comment
Please, Sign In to add comment