276
277
278
 
 

Answer: create a new object with the properties of the two original objects using the spread operator.

The order you insert the objects into the new merged object determines which object's properties take priority over the other.

Linked example:

const obj1 = { foo: "bar", x: 42 };
const obj2 = { foo: "baz", y: 13 };

const clonedObj = { ...obj1 };
// { foo: "bar", x: 42 }

const mergedObj = { ...obj1, ...obj2 };
// { foo: "baz", x: 42, y: 13 }

You can find more discussion here: https://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically

279
 
 

If you're like myself and forget over time what some of the more uncommonly used equality operators actually do under the hood, this resource is great for getting a quick explanation of the functionality and a general level of support across browsers.

Simply type in the operator you'd like an explanation for such as the nullish-coalescing operator (??) to get an immediate result. You can also select an operator from the list under the search if you're not immediately sure which operator you're looking for.

280
 
 

Svelte 4.0 Beta is out. The most important changes are the minimum requirement of Node 16, TypeScript 5 and Webpack 5 (although the use of Webpack is not recommended)

Svelte 4.0 focusses on structural improvements of the project and comes with better types for use in TypeScript. Even though the project, itself, is now moving to JSDoc (they say that this makes library development a lot faster). More impactful changes are expected in Svelte 5.

281
 
 

A great write-up about optimizing a set of functions spread across a handful of popular JS libraries in a reasonably straightforward way to understand and replicate in the packages you know and use on a daily basis.