Problem/Motivation
Some of JavaScript checks object existence with typeof obj !== 'undefined'
and checks property existence in the object. For example, it checks drupalTranslations and its property exsitence with below code in the /misc/drupal.js.
if ( typeof drupalTranslations !== 'undefined'&& drupalTranslations.strings && drupalTranslations.strings[options.context] && drupalTranslations.strings[options.context][str] )
This code is redundant for current JavaScript because using optional chaining operator can makes code more shorter like below.
if (drupalTranslations?.strings?.[options.context]?.[str])
Proposed resolution
Use optional chaining operator.
Remaining tasks
User interface changes
No.
API changes
No.
Data model changes
No.