11种调用一个函数的方法

1、

console.log(1);

2、

(_ => console.log(2))();

3、

eval('console.log(3);');

4、

console.log.call(null, 4);

5、

console.log.apply(null, [5]);

6、

new Function('console.log(6)')();

7、

Reflect.apply(console.log, null, [7])

8、

Reflect.construct(function(){console.log(8)}, []);

9、

Function.prototype.apply.call(console.log, null, [9]);

10、

Function.prototype.call.call(console.log, null, 10);

11、

new (require('vm').Script)('console.log(11)').runInThisContext();
阅读余下内容
 

《“11种调用一个函数的方法”》 有 1 条评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注


京ICP备12002735号