Paul Miller’s es6-shim gives you functionality that will be in ECMAScript 6 (code-named ECMAScript.next), on ECMAScript 5 engines. It was initially based on a project of mine, but adds much new functionality, Node.js compatibility, and (not least) tests.
> "hello world".startsWith("hello") true > "hi".repeat(3) 'hihihi'
var copy = Object.create(Object.getPrototypeOf(orig), Object.getOwnPropertyDescriptors(orig)); var newFoo = Object.create(FooProto, Object.getOwnPropertyDescriptors({ instanceProp1: 123, instanceProp2: "abc" }));
> 0 === -0 true > Object.is(0, -0) false > NaN === NaN false > Object.is(NaN, NaN) true
> var m = new Map(); undefined > m.set("1", "foo"); undefined > m.set(1, "bar"); undefined > m.get("1") 'foo' > m.get(1) 'bar'"1" and 1 are (coerced to) the same key with arrays. Note that each object is considered different from any other object. Hence, the following map entry cannot be easily retrieved:
> m.set({}, "hello"); > m.get({}) // new object! undefined
npm install es6-shimAfterwards, you enable it in your project like this:
require("es6-shim");And you can play with it on the Node.js REPL, with the option of enabling it by default [2].