what does % do in javascript -
what does % do in javascript -
this question has reply here:
what % in javascript? 6 answersi'm trying convert javascript code java not know %
character between 2 numeric variables does:
testvalue= somevalue%anothervalue;
what mean or same statement in java?
i have in javascript
if(somevalue%2==1){ }
what %2
mean here?
it's modulus operator. returns "the first operand modulo sec operand", remainder when substract (or add) much of sec operand off/to of first, close possible 0.
for example:
5 % 2 == 1 ( 5 = 2*2 +1) 6 % 2 == 0 ( 6 = 2*3 +0) 1 % 5 == 2 ( 12 = 5*2 +2) -5 % 2 == -1 (-5 = 2*-2 -1) -6 % 2 == 0 (-6 = 2*-3 -0) -12 % 5 == -2 (-12 = 5*-2 -2) // ^ that's result of modulo.
javascript
Comments
Post a Comment