File tree 3 files changed +9
-3
lines changed
solution/2600-2699/2619.Array Prototype Last
3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -54,13 +54,15 @@ declare global {
54
54
}
55
55
56
56
Array .prototype .last = function () {
57
- return this [ this .length - 1 ] ?? - 1 ;
57
+ return this .length ? this . at ( - 1 ) : - 1 ;
58
58
};
59
59
60
60
/**
61
61
* const arr = [1, 2, 3];
62
62
* arr.last(); // 3
63
63
*/
64
+
65
+ export {};
64
66
```
65
67
66
68
### ** ...**
Original file line number Diff line number Diff line change @@ -46,13 +46,15 @@ declare global {
46
46
}
47
47
48
48
Array .prototype .last = function () {
49
- return this [ this .length - 1 ] ?? - 1 ;
49
+ return this .length ? this . at ( - 1 ) : - 1 ;
50
50
};
51
51
52
52
/**
53
53
* const arr = [1, 2, 3];
54
54
* arr.last(); // 3
55
55
*/
56
+
57
+ export {};
56
58
```
57
59
58
60
### ** ...**
Original file line number Diff line number Diff line change @@ -5,10 +5,12 @@ declare global {
5
5
}
6
6
7
7
Array . prototype . last = function ( ) {
8
- return this [ this . length - 1 ] ?? - 1 ;
8
+ return this . length ? this . at ( - 1 ) : - 1 ;
9
9
} ;
10
10
11
11
/**
12
12
* const arr = [1, 2, 3];
13
13
* arr.last(); // 3
14
14
*/
15
+
16
+ export { } ;
You can’t perform that action at this time.
0 commit comments