Quickly finding objects in large arrays
Finding an object with a specific property is slow in large arrays. We can speed this operation up by transforming the array to a lookup object.
Read full articleCompare a variable to null
using two equal signs to check if it is null
or undefined
at the same time.
if (value === null || value === undefined) {
// `value` is `null` or `undefined`
}
if (value == null) {
// `value` is `null` or `undefined`
}
if (value === null || value === undefined) {
// `value` is `null` or `undefined`
}
if (value == null) {
// `value` is `null` or `undefined`
}
if (value === null || value === undefined) {
// `value` is `null` or `undefined`
}
if (value == null) {
// `value` is `null` or `undefined`
}
if (value === null || value === undefined) {
// `value` is `null` or `undefined`
}
if (value == null) {
// `value` is `null` or `undefined`
}
Finding an object with a specific property is slow in large arrays. We can speed this operation up by transforming the array to a lookup object.
Read full articleWe commonly increment a number using the += operator. Did you know there are assignment shorthands for other operations as well?
Read full articleIf an arrow function immediately returns a value, we don’t have to write the return keyword. The function will still implicitly return that value.
Read full articleWhen a feature calls for the first five photos from a list and a link that says “27 more photos”, we can split the list into these two blocks.
Read full articleWhen creating Tailwind CSS-like utility classes, we can use Sass’ loops to save a lot of repetition.
Read full articleTo find the largest value in an array of numbers, we can spread that array into Math.max() instead of manually iterating over it.
Read full article