function length

Description

The length property indicates the number of named arguments that the function expects.

Example


function myFunction1(name){/*  ww  w  . jav  a  2s. c o  m*/
   console.log(name);
}

function myFunction2(num1, num2){
   return num1 + num2;
}

function myFunction3(){
   console.log("hi");
}

console.log(myFunction1.length);  //1
console.log(myFunction2.length);  //2
console.log(myFunction3.length);  //0

The code above generates the following result.





















Home »
  Javascript »
    Javascript Introduction »




Script Element
Syntax
Data Type
Operator
Statement
Array
Primitive Wrapper Types
Function
Object-Oriented
Date
DOM
JSON
Regular Expressions