JavaScript Talk (Day 6)

js can use Function to create functions

var func=new Function();

This object can convert strings to functions

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

func();

There is a built-in arguments variable in the function, according to which all the parameters passed by the function can be obtained; this allows us to use functions with variable parameter lists;

function test(){

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

    console.write(argument[i]);

  }

}

test(1,2,3,4);

How to use the instanceof keyword; determine whether the constructor exists on the prototype chain of the object;

function Person(){};

var p = new Person ();

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

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

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325300873&siteId=291194637