I've seen in a library something like that (Number is augmented by the function integer):
Number.prototype.integer = function () {
return Math[this < 0 ? 'ceil' : 'floor'](this);
}
console.log ((-10/3).integer());
What is going on here? What kind of pattern is that:
Math['ceil'](this)
Aucun commentaire:
Enregistrer un commentaire