Blog · GitLab (User) Created at 2018-1-20 15:05:43 Updated at 2018-2-16 10:31:18 Tomáš Hübelbauer
Remove in favor of Bloggo prefix

Obscure JavaScript Stuff

I read a blog post today, called JS things I never knew existed.

There's a few very interesting things I didn't know about:

void operator:

void async function() {
  // Start your server here

It evaluates it's argument and returns undefined, so the above is a nicer version of IIFE or calling the function by its name above its declaration.

, operator:

const value = (console.log('Providing value'), 7);
// `value` is `7`

This is good for logging things by debugging without having to restructure code a lot. Like with a conditional operator as shown in the original article.

Then there is the Intl API:

new Intl.DateTimeFormat('en-us', { year: 'numeric', month: 'long', day: 'numeric' }).format(new Date());

Pretty cool, browser compatibility is handsome, too.

Pipeline operator, mentioned next, is still coming, I'll wait for it to show up in TypeScript. I know this from F#, but didn't know it will appear in JS, too.

setTimeout without bind:

This one is super cool.

setTimeout(this.props.callback, 1000,, this.state.flag);

It invokes this.props.callback(, this.state.flag) without the need for cloning the delegate.

Great article overall. Best to keep an eye on Nick's blog in the future.

Changes (3)
2018-2-16 10:31:18 Tomáš Hübelbauer
Remove in favor of Bloggo prefix
2018-1-20 15:15:16 Tomáš Hübelbauer
Turn into a bloggo
2018-1-20 15:14:54 Tomáš Hübelbauer
Post about Nick's obscure JS stuff article
Comments E-mail me!