Problem/Motivation
In the core, to get the last item in an array, use array[array.length - 1]. Modern JavaScript makes this code shorter.
Proposed resolution
Use array.at(-1).
For example, in /themes/claro/js/mobile.install.js
Before:
if (steps[steps.length - 1].className === 'done') {
After:
if (steps.at(-1).className === 'done') {
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | Screenshot 2026-04-06 at 1.53.57 PM.png | 71.27 KB | smustgrave |
Issue fork drupal-3576258
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
tom kondaComment #3
tom kondaComment #6
tom kondaComment #7
tom kondaComment #8
smustgrave commentedWith the addition of default_admin believe there are other instances now.
Comment #9
tom kondaReplaced array[array.length - 1] in default_admin theme.
Comment #10
smustgrave commentedAdditional ones appear to be addressed.
Comment #11
quietone commentedWhat about this instance?
Is there a linting rule that can enforce this?
Comment #12
tom konda> What about this instance?
Fixed it.
> Is there a linting rule that can enforce this?
No, in the ESLint standard rules.
Comment #13
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.