5 ms·
His example has at least 2 missing semicolons. function Logger() { } // Log something to the console at a specified level Logger.prototype.log = function(lev
by jack9 11y ago
His example has at least 2 missing semicolons.
function Logger() { }
// Log something to the console at a specified level
Logger.prototype.log = function(level) {
console[level || 'log'].apply(console,[].slice.apply(arguments, 1));
}; // here
// Sugar functions for Logger.log
['info', 'warn', 'error'].forEach(function(level) {
Logger.prototype[level] = function () {
return this.log.apply(this, [level].concat(Array.from(arguments)));
}; // here
});
- deleted 11y ago[deleted]
- draw_down 11y agoAnd yet, not only does it still function as it should without those missing semicolons, the author didn't notice them missing. Hmm. Hmmmmm.
- 0942v8653 11y agoNot sure what you're trying to insinuate, but the first "// here" is the one that broke the code as mentioned in the article.
- nailer 11y agoSo, can someone fill me in why ASI doesn't cover the missing semi for the Logger.prototype.log value? I understand this is the case, I just want to know why. The value is set, it seems like it should end the statement.