On 22 June 2022, the 123nd Ecma General Assembly approved the ECMAScript 2022 language specification, which means that it’s officially a standard now.
Private slot checks are also called “ergonomic brand checks for private fields”. The following expression is such a check – it determines if obj has a private slot #privateSlot:
Method .at() of indexable values lets us read an element at a given index (like the bracket operator ) and supports negative indices (unlike the bracket operator):
If we add the flag /d to a regular expression, using it produces match objects that record the start and end index of each group capture (lines A and B):
Object.hasOwn(obj, propKey) provides a safe way to check if an object obj has an own (non-inherited) property with the key propKey: