I have javascript class, that contains some data, and two functions.
export class BookStore {
constructor() {
this._books = [
{ id: 1,title: "How to Learn JavaScript - Vol 1", info: "Study hard"},
{ id: 2,title: "How to Learn ES6", info: "Complete all exercises :-)"},
{ id: 3,title: "How to Learn React",info: "Complete all your CA's"},
{ id: 4,title: "Learn React", info: "Don't drink beers, until Friday (after four)"
}]
this._nextID= 5;
}
get books(){ return this._books;}
addBook(book){
book.id = this._nextID;
this._books.push(book);
this._nextID++;
}
}
Now I want to make an object of the class, and console log Its book items
const book =Object.create(BookStore)
console.log(book.books)
I have tried several things, like the Object creates method, and trying calling it directly.
import {BookStore} from './BookStore/BookStore.js'