samedi 28 janvier 2017

What kind of construct / pattern is that?

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