The ECMAScript proposal “Import assertions” (by Myles Borins, Sven Sauleau, Dan Clark, and Daniel Ehrenberg) introduces syntax for associating metadata with import statements. In this blog post, we examine what that looks like and why it’s useful.
for
vs. for-in
vs. .forEach()
vs. for-of
This blog post compares four ways of looping over Arrays:
The for
loop:
for (let index=0; index < someArray.length; index++) {
const elem = someArray[index];
// ···
}
The for-in
loop:
for (const key in someArray) {
console.log(key);
}
The Array method .forEach()
:
someArray.forEach((elem, index) => {
console.log(elem, index);
});
The for-of
loop:
for (const elem of someArray) {
console.log(elem);
}
for-of
is often the best choice. We’ll see why.
The iOS/iPadOS app iSH is available on the app store and runs Linux via x86 emulation. And you can install Node.js on it!
Recently, we have seen an uptick of JavaScript tools being written in languages other than JavaScript. This blog post lists a few examples and explains the appeal of not using JavaScript.
Update 2021-06-22: The 121st Ecma General Assembly approved the ECMAScript 2021 language specification, which means that it’s officially a standard now.
This blog post describes what’s new.
.item()
for Arrays, Typed Arrays, and stringsThe ECMAScript proposal “.item()
” (by Shu-yu Guo and Tab Atkins) introduces the mentioned method for indexable values (Arrays, Typed Arrays, strings). Given an index, the method returns the corresponding element. Its key benefit is that indices can be negative (-1
gets the last element, -2
the second last, etc.). This blog post examines .item()
in detail.
Update November 2020: The method name .item()
ended up not being web-compatible. The tentative new name is .at()
.
This blog post explains how to get started with React while using as few libraries as possible.
In this blog post, we look at three approaches for eliminating duplicate objects from Arrays.
This post explains private static methods and accessors in classes, as described in the ECMAScript proposal “Static class features” by Shu-yu Guo and Daniel Ehrenberg.
In this blog post, we explore how we can compute with types at compile time in TypeScript.
Note that the focus of this post is on learning how to compute with types. Therefore, we’ll use literal types a lot and the examples are less practically relevant. Future blog posts will cover real-world use cases.