Add listings of new built-in methods
webbedspace opened this issue · comments
Leon commented
Here's some ES5 equivalents of a few such methods to get you started.
Object.assign:
var src1 = { foo: 1, bar: 2 };
var src2 = { foo: 3, baz: 3 };
var dst = {};
Object.keys(src).forEach(function(e) {
dst[e] = src[e];
});
Object.keys(src2).forEach(function(e) {
dst[e] = src2[e];
});
dst.foo; // 3
dst.bar; // 2
dst.baz; // 3
Array.find:
[1,3,4,2].filter(function(e) { return e > 3; })[0]; // 4
String.prototype.repeat:
(Array(12)+",").replace(/,/g, "red"); // "redredredredredredredredredredredred"
Denis Pushkarev commented
@webbedspace Array(13).join('red')
Dr. Ralf S. Engelschall commented
Ok, added multiple examples related to new built-in methods, including your examples. Thanks for your contribution.