Javascript Class create class with constructor

Description

Javascript Class create class with constructor

class Book {/*  ww w . j  av a2 s.  co  m*/
    constructor (title, pages, isbn) {
        this.title = title;
        this.pages = pages;
        this.isbn = isbn;
    }
    printIsbn(){
        console.log(this.isbn);
    }
}

let book = new Book('title', 'pag',  'isbn');

console.log(book.title); //outputs the book title

book.title = 'new title'; //update the value of the book title

console.log(book.title); //outputs the book title



PreviousNext

Related