var Book = function(newIsbn,newTitle,newAuthor) { implements Publication
Private attributes.
var isbn,title,author;
Private method.
checkIsbn(isbn) {
...
return true;
}
Privileged methods.
this.getIsbn = () {
isbn;
};
this.setIsbn = (newIsbn) {
if(!checkIsbn(newIsbn)) throw new Error('Book: Invalid ISBN.');
isbn = newIsbn;
};
this.getTitle = title;
};
this.setTitle = (newTitle) {
title = newTitle || 'No title specified';
};
this.getAuthor = author;
};
this.setAuthor = (newAuthor) {
author = newAuthor || 'No author specified' Constructor code.
this.setIsbn(newIsbn);
.setTitle(newTitle);
.setAuthor(newAuthor);
};
Public,non-privileged methods.
Book.prototype = {
display: ...
}
};
var mybook=new Book("myisbtn","mytittle","myauthor");
console.log(mybook.getAuthor());