js中可以使用Function创建函数

var func=new Function();

这个对象可以将字符串转换为函数

var func=new Function("console.write('hello world')");

func();

函数中有内置的arguments变量,根据这个变量可以获取到函数传递过来的所有参数;这就使我们可以使用可变参数列表的函数;

function test(){

  for(var i=0;i<arguments.length;i++){

    console.write(argument[i]);

  }

}

test(1,2,3,4);

instanceof 关键字的使用方法;判断构造函数是否存在于对象的原型链上;

function Person(){};

var p=new Person();

console.write(p instanceof Person);//true;

console.write(p instanceof Object);//true;

 

相关文章:

  • 2021-10-06
  • 2021-12-12
猜你喜欢
  • 2021-05-08
  • 2022-01-05
  • 2021-11-14
  • 2021-07-21
  • 2021-06-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案