Index array based on function
Creates an object from an array, using a function to map each value to a key.
The JavaScript snippet collection contains a wide variety of ES6 helper functions. It includes helpers for dealing with primitives, arrays and objects, as well as algorithms, DOM manipulation functions and Node.js utilities.
Creates an object from an array, using a function to map each value to a key.
Have you ever wanted to serialize an object but only include certain keys? Turns out JavaScript provides an easy way to do this!
JavaScript's this
keyword can confuse beginners and veterans alike. Learn how it works in different scenarios and start using it correctly.
Convert all the keys of an object to upper or lower case.
Groups the elements of an array based on the given function.
Learn how to transform objects by filtering their properties based on an array of keys or a predicate function.
Inverts the key-value pairs of an object, without mutating it.
Using the Proxy object, we can create dynamic getters and setters for objects in JavaScript.
Learn how mutability works in JavaScript, its applications to objects and how you can properly freeze them to make them constant.
Learn the basics of the destructuring assignment syntax in JavaScript ES6 and improve your code with this easy guide.
Iterate over all own properties of an object, running a callback for each one.
A quick introduction to the JavaScript Proxy object and where it can be used.
Pretty-printing JSON objects in pretty easy and customizable in JavaScript. Here's the gist of it.
JavaScript's strict mode can make your code faster, cleaner and more secure.
Map the values of an array to an object, using the given mapping functions.
Nests recursively objects linked to one another in a flat array.
Adding a key-value pair to a JavaScript object is straightforward, yet there are multiple ways available to do so.
Using the Proxy object, we can create chainable dynamic getters for objects in JavaScript.
Both Object.freeze()
and Object.seal()
serve a similar purpose, but there's one key difference you need to remember.
Circular JSON objects can't be serialized using JSON.stringify()
, but you can use this trick to handle them.
JavaScript's switch
statement often feels hard to remember and a little bit out of place. Maybe it's time to use object literals, instead.
Learn how to type check objects at runtime using the powerful Proxy object in JavaScript.
Creates a generator, that walks through all the keys of a given object.
Performs a deep comparison between two values to determine if they are equivalent.