Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
863 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var DESCRIPTORS = require('../internals/descriptors');
|
---|
3 | var addToUnscopables = require('../internals/add-to-unscopables');
|
---|
4 | var toObject = require('../internals/to-object');
|
---|
5 | var toLength = require('../internals/to-length');
|
---|
6 | var defineProperty = require('../internals/object-define-property').f;
|
---|
7 |
|
---|
8 | // `Array.prototype.lastIndex` accessor
|
---|
9 | // https://github.com/keithamus/proposal-array-last
|
---|
10 | if (DESCRIPTORS && !('lastItem' in [])) {
|
---|
11 | defineProperty(Array.prototype, 'lastItem', {
|
---|
12 | configurable: true,
|
---|
13 | get: function lastItem() {
|
---|
14 | var O = toObject(this);
|
---|
15 | var len = toLength(O.length);
|
---|
16 | return len == 0 ? undefined : O[len - 1];
|
---|
17 | },
|
---|
18 | set: function lastItem(value) {
|
---|
19 | var O = toObject(this);
|
---|
20 | var len = toLength(O.length);
|
---|
21 | return O[len == 0 ? 0 : len - 1] = value;
|
---|
22 | }
|
---|
23 | });
|
---|
24 |
|
---|
25 | addToUnscopables('lastItem');
|
---|
26 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.