mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-08-27 02:31:17 -04:00
d314d02335
Signed-off-by: getingke <getingke@huawei.com> Change-Id: I6bd8842e81a7cce061190fff86345b98bb5b660e
23 lines
467 B
TypeScript
23 lines
467 B
TypeScript
declare function print(str:any):string;
|
|
|
|
|
|
|
|
function sum(a:number, b:number):number {
|
|
return a + b;
|
|
}
|
|
|
|
const handler = {
|
|
apply: function(target:any, thisArg:any, argumentsList:any[]) {
|
|
print(`Calculate sum: ${argumentsList}`);
|
|
// expected output: "Calculate sum: 1,2"
|
|
|
|
return target(argumentsList[0], argumentsList[1]) * 10;
|
|
}
|
|
};
|
|
|
|
const proxy1 = new Proxy(sum, handler);
|
|
|
|
print(sum(1, 2));
|
|
// expected output: 3
|
|
print(proxy1(1, 2));
|