JS advanced — several members of function


Several members of a function


  • There is a name attribute in the function —– > the name of the function. The name attribute is read-only and cannot be modified
  • Function has an arguments attribute — > the number of arguments
  • There is a length attribute in the function —– > the number of parameters when the function is defined
    function f1(x, y) {
      console.log(f1.name); //f1
      console.log(f1.arguments.length); //4
      console.log(f1.length); //2

    f1.name = "f5";
    f1(10, 20, 30, 40);



  • There is a caller attribute in the function — > Call (F1 function is called in F2 function, so the caller is F2).


function f1(x, y) {
      console.log (F1. Caller); // caller F2

    function f2() {
      console.log ("code for F2 function");
      f1(1, 2);