Avoid coercing position in _.startsWith, if it’s undefined.

This commit is contained in:
John-David Dalton
2016-12-21 12:33:46 -06:00
parent 6c1ae0b54d
commit 32fdfcc1e5

View File

@@ -14631,7 +14631,10 @@
*/
function startsWith(string, target, position) {
string = toString(string);
position = baseClamp(toInteger(position), 0, string.length);
position = position === undefined
? 0
: baseClamp(toInteger(position), 0, string.length);
target = baseToString(target);
return string.slice(position, position + target.length) == target;
}