📄 3.03 - private methods with underscores.js
字号:
var Book = function(isbn, title, author) { // implements Publication this.setIsbn(isbn); this.setTitle(title); this.setAuthor(author);}Book.prototype = { _checkIsbn: function(isbn) { ... }, getIsbn: function() { return this._isbn; }, setIsbn: function(isbn) { if(!this._checkIsbn(isbn)) throw new Error('Book: Invalid ISBN.'); this._isbn = isbn; }, getTitle: function() { return this._title; }, setTitle: function(title) { this._title = title || 'No title specified'; }, getAuthor: function() { return this._author; }, setAuthor: function(author) { this._author = author || 'No author specified'; }, display: function() { ... }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -