Hi,
I don't think Array.of() is useful, just stick on array literal seems enough:
var a = [1,2,3]
var a1 = [3]
Why we need this:
var a = Array.of(1,2,3)
var a1 = Array.of(3)
Is there any special benefit I missed?
And there is another reason why I don't like Array.of() , myself write
a small library which use Array.of(type) to get a "strong-typed"
array:
var StringArray = Array.of(String)
var a = StringArray.from(['a', 1, true]) // ['a', '1', 'true']
a.push('string') // ['a', '1', 'true', 'string']
a.push(100) // throws error
And Function.of() :
var sqrt = Function.of(Number).from(Math.sqrt)
sqrt(9) // 3
sqrt('9') // error
sqrt(9, 'unwanted') // error
--
hax
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss