Last active
December 22, 2015 08:49
-
-
Save zhanhongtao/6447743 to your computer and use it in GitHub Desktop.
Math.min & Math.max call/apply
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = 80; | |
var MAX_VALUE = 50; | |
var MIN_VALUE = 0; | |
// result 值不能小于 0 | |
result = Math.max.call( Math, MIN_VALUE, result ); | |
result = Math.min.apply( Math, [ MAX_VALUE, result ] ); | |
console.log( result ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment