Register for this year’s #ChromeDevSummit happening on Nov. 11-12 in San Francisco to learn about the latest features and tools coming to the Web. Request an invite on the Chrome Dev Summit 2019 website

Public class fields

My first language was Java, and learning JavaScript threw me for a bit of a
loop. How did I create a class? Or inheritance? What about public and private
properties and methods? Many of the recent updates to JavaScript that make
object oriented programming much easier.

I can now create classes, that work like I expect them
to, complete with constructors, getters and setters, static methods and public
properties.

Thanks to V8 7.2, which ships with Chrome 72, you can now declare public class
fields directly in the class definition, eliminating the need to do it in the
constructor.

More details are in Mathias’s article on
class fields for more details.

User Activation API

Remember when sites could automatically play sound as soon as the page loaded?
You scramble to hit the mute key, or figure out which tab it was, and close it.
That’s why some APIs require activation via a user gesture before they’ll work.
Unfortunately, browsers handle activation in different ways.

User activation API before and after user has interacted with the page.

Chrome 72 introduces User Activation v2, which simplifies user activation for
all gated APIs. It’s based on a new specification that aims to
standardize how activation works across all browsers.

There’s a new userActivation property on both navigator and MessageEvent,
that has two properties: hasBeenActive and isActive:

hasBeenActive indicates if the associated window has ever seen a user
activation in its lifecycle.

isActive indicates if the associated window currently has a user
activation in its lifecycle.

Localizing lists of things with Intl.format

I love the Intl APIs, they’re super helpful for localizing content into
other languages! In Chrome 72, there’s a new .format() method that makes
rendering lists easier. Like other Intl APIs, it shifts the burden to the
JavaScript engine, without sacrificing performance.

Initialize it with the locale you want, then call format, and it’ll use the
correct words and syntax. It can do conjunctions - which adds the localized
equivalent of and (and look at those beautiful oxford commas). It can do
disjunctions - adding the local equivalent of or. And by providing some
additional options, you can do even more.