Removing specific values from an array
This helper function lets us remove all instances of specific values from an array.
Read full articleYou can use non-standard characters like “:” in CSS class names if you escape them with a backslash. Libraries like Tailwind CSS do that a lot for adding state selectors like hover:
or focus:
.
<style>
.text\:italic {
font-style: italic;
}
.text\:uppercase {
text-transform: uppercase;
}
</style>
<p class="text:italic text:uppercase">
Italic and uppercase
</p>
<style>
.text\:italic {
font-style: italic;
}
.text\:uppercase {
text-transform: uppercase;
}
</style>
<p class="text:italic text:uppercase">
Italic and uppercase
</p>
<style>
.text\:italic {
font-style: italic;
}
.text\:uppercase {
text-transform: uppercase;
}
</style>
<p class="text:italic text:uppercase">
Italic and uppercase
</p>
<style>
.text\:italic {
font-style: italic;
}
.text\:uppercase {
text-transform: uppercase;
}
</style>
<p class="text:italic text:uppercase">
Italic and uppercase
</p>
This helper function lets us remove all instances of specific values from an array.
Read full articleWe can create a sequence of numbers by spreading the keys of one array into another array. We can then change that range any way we like.
Read full articleWhen your data can contain “outliers” that are clearly unintentional, you can clamp them to all fall within the same valid range.
Read full articleWe can use the value returned by Math.random() to get a random element from an array.
Read full articleAn “XOR” operation returns the elements that only exist in one of two arrays, but not both.
Read full articleThere is no “array” type in JavaScript. To check if something is an array, we can use a helper on the Array prototype.
Read full article