Home > Back-end >  [new industry for help] js interpretation why 6 already more than 12 less than zero
[new industry for help] js interpretation why 6 already more than 12 less than zero

Time:11-07

Recently received a project, I met a very strange question,
Input entered 6, and then to determine whether a value in the upper (12) and lower limit (0)
No problem, local environment to the test environment there will be 6 is greater than 12 less than 0
the condition of theThe code is as follows:
/* *
* limit the maximum and the minimum
* @ param Max Max
* @ param min min
* @ param includeMax does it include the maximum y/n
* @ param includeMin does it include the minimum y/n
*/
Dynamic. Prototype. Limited=function (Max, min, includeMax includeMin, e) {

Var e=e | | window. The event;//get event
Var ele=e. arget | | e.s rcElement;//get trigger element
Var $dom=$(ele);
Var val=$dom. Val ()
The console. The log (Max, min, includeMax includeMin, val, val & gt;=Max, val & lt;=min);
The console. The log (parseInt (val));
IncludeMin includeMin of====undefined?" No ": includeMin
IncludeMax includeMax of====undefined?" No ": includeMax
If (val==="") {
$dom. Val (" ")
} else if (parseInt (val) & gt;=Max) {
Max includeMax of===="yes"? Max: Max - 1
$dom. Val (Max)
} else if (parseInt (val) & lt; Min)={
Min=includeMin==="yes"? Min: min + 1
$dom. Val (min)
}
}
  • Related