Issue #20 - Internals of v8 engine, generating code snippets from terminal and more
Learn how to write better tests with implicit assertions, solve common UI problems easily with modern CSS, create high-quality images of code snippets and terminal output straight from your terminal, and test your understanding of generators in JavaScript.
Tip of the day
We can use the Intl.PluralRules
API to format numbers with their st, nd, rd and th ordinals.
const pr = new Intl.PluralRules('en-US', {
type: 'ordinal',
});
const numberformatter = new Intl.NumberFormat('en-US');
const suffixes = new Map([
['one', 'st'],
['two', 'nd'],
['few', 'rd'],
['other', 'th'],
]);
function formatNumber(n: number) {
const rule = pr.select(n); // 'one', 'two', 'few', 'other'
const suffix = suffixes.get(rule);
return `${numberformatter.format(n)}${suffix}`;
}
formatNumber(1); // 1st
formatNumber(2); // 2nd
formatNumber(123453); // 123,453rd
formatNumber(5555); // 5,555th
Articles
Have a better understanding about the explicit and implicit assertions now, and perhaps even have a test or two in mind to improve.
by Artem Zakharchenko
Smart CSS Solutions For Common UI Challenges
Writing CSS has probably never been more fun and exciting than it is today. In this post we look at common problems, use cases and how to solve them with modern CSS.
by Cosima Mielke
Tools
Freeze let’s you generate high quality PNGs, SVGs and WEBPs of code and terminal output directly from your terminal.
by Charm
Easily click to copy unicodes that are commonly used when designing interfaces.
by Benjamin Hoppe
Tech Talks
Understanding the V8 JavaScript Engine
Learn with visualizations how JavaScript code written for humans gets compiled and optimized to code that machines understand
by Lydia Hallie
Quiz
What is wrong with the following snippet?
function* getSquares(limit) {
for (i = 1; i <= limit; i++) {
yield i * i;
}
}
for (const number in getSquares(3)) {
console.log(number);
}
This week in GIF
When a colleague forwards me a bunch of tickets while I’m in the middle of coding
Liked this issue? Share on Twitter or read previous issues.