mathiasbynens / Array.from

A robust & optimized ES3-compatible polyfill for the `Array.from` method in ECMAScript 6.

Home Page:https://mths.be/array-from

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arrays are read only?

stompychump opened this issue · comments

Thank you for this polyfill. One question: created arrays appear to be read only, as assigning results in "TypeError: Cannot assign to read only property" in strict mode. For example:

'use strict';
var a = Array.from([1, 2, 3]);
a[1] = 7;

Adding a writable:true to the defineProperty descriptor on line 68 solved it for me. Just wondering if this was intentional, or am I missing something?

Tested in Chromium 27, and compared with the native implementation in Firefox 36.

@stompychump line 68 already says writable true https://github.com/mathiasbynens/Array.from/blob/master/array-from.js#L72 - do you have the latest version?

Oops, I see that writable:true was added in July, but I was testing with an earlier version. I should have checked for the latest release, sorry.