サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
インタビュー
2ality.com
What is TypeScript? An overview for JavaScript programmers Read this blog post if you are a JavaScript programmer and want to get a rough idea of what using TypeScript is like (think first step before learning more details). You’ll get answers to the following questions: How is TypeScript code different from JavaScript code? How is TypeScript code run? How does TypeScript help during editing in an
TypeScript’s satisfies operator lets us check the type of a value (mostly) without influencing it. In this blog post, we examine how exactly it works and where it’s useful. Notation used in this blog post # For showing computed and inferred types in source code, I use the npm package asserttt – e.g.: // Types of values assertType<string>('abc'); assertType<number>(123); // Equality of types type
Ecma International approves ECMAScript 2024: What’s new? On 26 June 2024, the 127th Ecma General Assembly approved the ECMAScript 2024 language specification (press release, GitHub release), which means that it’s officially a standard now. This blog post explains what’s new. The editors of ECMAScript 2024 # The editors of this release are: Shu-yu Guo Michael Ficarra Kevin Gibbons What’s new in EC
In this blog post, we take a look at the ECMAScript 2023 feature “Symbols as WeakMap keys” – which was proposed by Robin Ricard, Rick Button, Daniel Ehrenberg, Leo Balter, Caridy Patiño, Rick Waldron, and Ashley Claymore. What are WeakMaps good for? # The key ability of a WeakMap is to associate data with a value: The value is the key of a WeakMap entry. The data is the value of that entry. Consi
Update 2022-12-15: New section “How will this proposal affect future JavaScript APIs?” In this blog post, we look at the ECMAScript proposal “Iterator helpers” by Gus Caplan, Michael Ficarra, Adam Vandolder, Jason Orendorff, Kevin Gibbons, and Yulia Startsev. It introduces utility methods for working with iterable data: .map(), .filter(), .take(), etc. The style of the proposed API clashes with th
This blog post is about the ECMAScript proposal “Array.fromAsync for JavaScript” by J. S. Choi. It introduces a static method for converting asynchronous iterables to Arrays. Tools for working with synchronous iterables # Currently JavaScript provides several tools for working with synchronous iterables – for example: function* createSyncIterable() { yield 'a'; yield 'b'; yield 'c'; } // Array-de
ECMAScript proposal: RegExp flag /v makes character classes and character class escapes more powerful In this blog post, we look at the ECMAScript proposal “RegExp v flag with set notation + properties of strings” by Markus Scherer and Mathias Bynens. The new flag /v # The proposed new regular expression flag /v (.unicodeSets) enables three features: Support for multi-code-point graphemes (such a
More information on the syntax and semantics of decorators (optional section) # (This section is optional. If you skip it, you can still understand the remaining content.) The syntax of decorator expressions # A decorator expression starts with a chain of one or more identifiers, separated by dots. Each identifier except the first one can be private (prefix #). Square brackets [] are not allowed
Warning: This blog post is outdated. Instead, read chapter “An overview of Node.js: architecture, APIs, event loop, concurrency” in “Shell scripting with Node.js”. This blog post gives an overview of how Node.js works: What its architecture looks like. How its APIs are structured. A few highlights of its global variables and built-in modules. How it runs JavaScript in a single thread via an event
Warning: This blog post is outdated. Instead, read chapter “Running shell commands in child processes” in “Shell scripting with Node.js”. In this blog post, we’ll explore how we can execute shell commands from Node.js, via module 'node:child_process'. Overview of this blog post # Module 'node:child_process' has a function for executing shell commands (in spawned child processes) that comes in two
Ecma International approves ECMAScript 2022: What’s new? On 22 June 2022, the 123nd Ecma General Assembly approved the ECMAScript 2022 language specification, which means that it’s officially a standard now. This blog post explains what’s new. The editors of ECMAScript 2022 # The editors of this release are: Shu-yu Guo Michael Ficarra Kevin Gibbons What’s new in ECMAScript 2022? # New members of
Processing Arrays non-destructively: for-of vs. .reduce() vs. .flatMap() In this blog post, we look at three ways of processing Arrays: The for-of loop The Array method .reduce() The Array method .flatMap() The goal is to help you choose between these features whenever you need to process Arrays. In case you don’t know .reduce() and .flatMap() yet, they will both be explained to you. In order to g
(This blog post is based on a tweet thread and additional input by Mathias Bynens.) After work started on it in August 2017, May 2022 finally saw the publication of RFC 9239 “Updates to ECMAScript media types” by Matthew A. Miller, Myles Borins, Mathias Bynens, and Bradley Farias. It updates JavaScript MIME type registrations to align with reality: The JavaScript MIME type is now unambiguously tex
The triple dot syntax (...) in JavaScript: rest vs. spread In JavaScript, the same syntax – triple dots (...) – is used for two different mechanisms: Rest syntax is for receiving data. Spreading is for sending data. This blog post examines how these mechanisms work and why they are not operators. Receiving data: rest syntax # A rest parameter is a special kind of parameter that receives all remai
ECMAScript proposal “Change Array by copy”: four new non-destructive Array methods This blog post describes the ECMAScript proposal “Change Array by copy” by Robin Ricard and Ashley Claymore. It proposes four new methods for Arrays and Typed Arrays: .toReversed() .toSorted() .toSpliced() .with() The new methods are for Arrays and TypedArrays # This blog post only demonstrates the new methods with
Update 2022-03-10: I’m quoting a few insightful tweets at the end of this blog post. The ECMAScript proposal “Types as comments” (by Gil Tayar, Daniel Rosenwasser, Romulo Cintra, Rob Palmer, and others) is about adding type annotations to JavaScript (there is also an accompanying blog post). Such type annotations would look similar to TypeScript’s and Flow’s annotations and are completely ignored
This blog post is first in a series of two: What are wrapper objects for primitive values? How do primitive values get their properties? Each of the primitive types boolean, number, bigint, string and symbol has an associated wrapper class (Boolean, Number, BigInt, String, Symbol). In this blog post, we examine what these classes are good for. Wrapper classes for primitive types # This is an exha
The proposal “Pipe operator (|>) for JavaScript” (by J. S. Choi, James DiGioia, Ron Buckton and Tab Atkins) introduces a new operator. This operator is an idea borrowed from functional programming that makes applying functions more convenient in many cases. This blog post describes how the pipe operator works and what its use cases are (there are more than you might expect!). The two competing pro
Node.js now supports a node: protocol for built-in modules. The new node: protocol # Previously: import * as fs from 'fs/promises'; Now: import * as fs from 'node:fs/promises'; Benefits of node: imports # What are the benefits of using node: module specifiers? It’s immediately clear that a built-in Node.js module is imported. Given how many of them there now are, that’s useful information. There
The ECMAScript proposal “Class static initialization blocks” by Ron Buckton is at stage 4 and scheduled to be included in ECMAScript 2022. For setting up an instance of a class, we have two constructs in JavaScript: Field: Create (and optionally initialize) instance properties. Constructor: A block of code that is executed before setup is finished. For setting up the static part of a class, we onl
JavaScript needs more helper functions for iteration (map, filter, etc.) – where should we put them? Iteration is a standard that connects operations with data containers: Each operation that follows this standard, can be applied to each data container that implements this standard. In this blog post: We first explore three questions: How does JavaScript’s iteration work? What are its quirks? What
Simple monorepos via npm workspaces and TypeScript project references A monorepo is a single repository that is used to manage multiple projects. In this blog post, we’ll explore how to set up a simple monorepo for two npm packages. All we need is already built into npm and TypeScript. What is a monorepo and why is it useful? # Whenever we have to develop multiple interdependent npm packages in p
In this blog post, I’ll explain everything you need to know in order to use and produce native ECMAScript modules on Node.js. The GitHub repository iterable is an example of a TypeScript ESM package that works on Node.js. It still uses the "typesVersions" workaround (which isn’t needed in TypeScript 4.7 and later). (Thanks to Guy Beford and Oleg Drapeza for their feedback on this post.) TypeScript
Temporal: getting started with JavaScript’s new date time API Updates: 2022-01-10: Temporal.now was renamed to Temporal.Now. 2021-06-30: Rearranged the content and created a section on the concepts and patterns used by the Temporal API. 2021-06-29: Clarified how Instant uses the ISO-8601 calendar. Listed the properties of some classes. Date, JavaScript’s current date time API is infamously difficu
In this blog post, we examine the ECMAScript proposal “JSON modules” (by Sven Sauleau, Daniel Ehrenberg, Myles Borins, and Dan Clark). It lets us import JSON data as if it were an ECMAScript module. Why would we want to import JSON like a module? # Various bundlers (such as webpack) have allowed us to import JSON data as if it were an ECMAScript module for a long time. JSON modules turn this into
Many programming languages have one “non-value” called null. It indicates that a variable does not currently point to an object – for example, when it hasn’t been initialized yet. In contrast, JavaScript has two such non-values: undefined and null. In this blog post, we examine how they differ and how to best use or avoid them. undefined vs. null # Both values are very similar and often used inte
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. Import assertions # The motivating use case for import assertions was importing JSON data as a module. That looks as follows (and is further specified
Writing JavaScript tools in other languages – a new trend? 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. Examples # I asked on Twitter and these are a few of the examples that people mentioned: Build tools and compilers: esbuild – Go: JavaScript bundler and
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. The editors of ECMAScript 2021 # The editors of this release are: Jordan Harband Shu-yu Guo Michael Ficarra Kevin Gibbons A word on ECMAScript versions # Note that since the TC39 process was instituted, the i
次のページ
このページを最初にブックマークしてみませんか?
『2ality – JavaScript and more』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く