mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-08 10:36:02 +00:00
LibJS: Use the function's bound |this| and bound arguments in
Interpreter::call()
This commit is contained in:
parent
3ffb0a4e87
commit
f4129ac422
Notes:
sideshowbarker
2024-07-19 05:58:15 +09:00
Author: https://github.com/jack-karamanian
Commit: f4129ac422
Pull-request: https://github.com/SerenityOS/serenity/pull/2454
2 changed files with 14 additions and 2 deletions
|
@ -11,6 +11,17 @@ try {
|
|||
}
|
||||
assert(getB.bind("bar")() === "B");
|
||||
|
||||
// Bound functions should work with array functions
|
||||
var Make3 = Number.bind(null, 3);
|
||||
assert([55].map(Make3)[0] === 3);
|
||||
|
||||
var MakeTrue = Boolean.bind(null, true);
|
||||
assert([1, 2, 3].filter(MakeTrue).length === 3);
|
||||
|
||||
assert([1, 2, 3].reduce((function (acc, x) { return acc + x }).bind(null, 4, 5)) === 9);
|
||||
|
||||
assert([1, 2, 3].reduce((function (acc, x) { return acc + x + this; }).bind(3)) === 12);
|
||||
|
||||
function sum(a, b, c) {
|
||||
return a + b + c;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue