mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibJS: Use a non-arrow function to check the |this| value in the
callback for Array.prototype.{reduce,reduceRight} Arrow functions always retain the |this| binding. Running this code in Node: [1, 2].reduce(() => { "use strict"; console.log(this === undefined) } Output: false
This commit is contained in:
parent
4a49c8412c
commit
d4e97b17ab
Notes:
sideshowbarker
2024-07-19 05:58:08 +09:00
Author: https://github.com/jack-karamanian
Commit: d4e97b17ab
Pull-request: https://github.com/SerenityOS/serenity/pull/2454
2 changed files with 2 additions and 2 deletions
|
@ -31,7 +31,7 @@ try {
|
|||
message: "Reduce of empty array with no initial value"
|
||||
});
|
||||
|
||||
[1, 2].reduce(() => { assert(this === undefined) });
|
||||
[1, 2].reduce(function () { assert(this === undefined) });
|
||||
|
||||
var callbackCalled = 0;
|
||||
var callback = () => { callbackCalled++; return true };
|
||||
|
|
|
@ -43,7 +43,7 @@ try {
|
|||
}
|
||||
);
|
||||
|
||||
[1, 2].reduceRight(() => {
|
||||
[1, 2].reduceRight(function () {
|
||||
assert(this === undefined);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue