ExtensionMethod.NET Home of 820 C#, Visual Basic, F# and Javascript extension methods

IsEven

Returns true if the number is an even number

Source

Number.prototype.IsEven = function () {
    return this % 2 == 0;
}

Example

if (self.row.IsEven()) {
    xoffset -= 75;
}

Author: Loek van den Ouweland

Submitted on: 16 apr 2013

Language: JavaScript

Type: Number

Views: 3551