Avoid more coercion.

This commit is contained in:
John-David Dalton
2016-12-21 15:21:21 -06:00
parent 32fdfcc1e5
commit e2c703a96f

View File

@@ -5454,7 +5454,7 @@
var func = Math[methodName];
return function(number, precision) {
number = toNumber(number);
precision = nativeMin(toInteger(precision), 292);
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
if (precision) {
// Shift with exponential notation to avoid floating-point issues.
// See [MDN](https://mdn.io/round#Examples) for more details.
@@ -10852,7 +10852,7 @@
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
start = start == null ? 0 : nativeMax(toInteger(start), 0);
return baseRest(function(args) {
var array = args[start],
otherArgs = castSlice(args, 0, start);
@@ -12542,7 +12542,9 @@
* // => 3
*/
function toSafeInteger(value) {
return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
return value
? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
: (value === 0 ? value : 0);
}
/**
@@ -14631,7 +14633,7 @@
*/
function startsWith(string, target, position) {
string = toString(string);
position = position === undefined
position = position == null
? 0
: baseClamp(toInteger(position), 0, string.length);