From 46704724e35699ab07e297258138e70f50406ab9 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 11 Jul 2014 08:57:51 -0700 Subject: [PATCH] Add comments to `_.escape` and `_.repeat`. [ci skip] --- lodash.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lodash.js b/lodash.js index 7744b2185..43d8d2d73 100644 --- a/lodash.js +++ b/lodash.js @@ -7792,6 +7792,7 @@ * // => 'fred, barney, & pebbles' */ function escape(string) { + // reset `lastIndex` because in IE < 9 `String#replace` does not string = string == null ? '' : String(string); return (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string)) ? string.replace(reUnescapedHtml, escapeHtmlChar) @@ -7967,6 +7968,9 @@ return result; } string = String(string); + + // leverage the exponentiation by squaring algorithm for a faster repeat + // http://en.wikipedia.org/wiki/Exponentiation_by_squaring do { if (n % 2) { result += string;