Scriptified logo

Scriptified

Subscribe
Archives
April 16, 2024

Issue #20 - Internals of v8 engine, generating code snippets from terminal and more

Headshot

Read issue on web

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

Implicit Assertions

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

Freeze let’s you generate high quality PNGs, SVGs and WEBPs of code and terminal output directly from your terminal.

by Charm

Common

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);
}

Generator functions cannot be iterated
function* is not a valid syntax in JavaScript
for…of loop should be used instead of for…in loop
yield is not a valid keyword in JavaScript, use return instead


This week in GIF

When a colleague forwards me a bunch of tickets while I’m in the middle of coding

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.

Don't miss what's next. Subscribe to Scriptified:
GitHub X
Powered by Buttondown, the easiest way to start and grow your newsletter.