diff --git a/lodash.src.js b/lodash.src.js index e43613f62..c22ae7678 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -803,12 +803,19 @@ // // Use `Object.preventExtensions` on a plain object instead of simply using // `Object('x')` because Chrome and IE fail to throw an error when attempting - // to assign values to readonly indexes of strings in strict mode. - var object = { '1': 0 }, - func = preventExtensions && isNative(func = Object.assign) && func; - - try { func(preventExtensions(object), 'xo'); } catch(e) {} - return !object[1] && func; + // to assign values to readonly indexes of strings. + var func = preventExtensions && isNative(func = Object.assign) && func; + try { + if (func) { + var object = preventExtensions({ '1': 0 }); + object[0] = 1; + } + } catch(e) { + // Only attempt in strict mode. + try { func(object, 'xo'); } catch(e) {} + return !object[1] && func; + } + return false; }()); /* Native method references for those with the same name as other `lodash` methods. */