Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
Add Array.prototype.at polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
maltejur committed Oct 27, 2023
1 parent 71ab75b commit 3f3f179
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions assets/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

const hasOwn = function hasOwn(o, p) {
Object.hasOwn = function (o, p) {
const obj = Object(o);
const key = String(p);
return Object.prototype.hasOwnProperty.call(obj, key);
}

Object.hasOwn = hasOwn;
Array.prototype.at = function (index) {
if (index >= 0) {
return this[index];
} else {
return this[this.length + index];
}
};

0 comments on commit 3f3f179

Please sign in to comment.