Skip to content

Instantly share code, notes, and snippets.

@zhanhongtao
Last active December 22, 2015 08:49
Show Gist options
  • Save zhanhongtao/6447743 to your computer and use it in GitHub Desktop.
Save zhanhongtao/6447743 to your computer and use it in GitHub Desktop.
Math.min & Math.max call/apply
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