Skip to content

Function Length

Why function.length?

The Length property is a property of the function object. Return the number of parameters in the function. Does not include the Rest parameter. The length of an empty string is 0.

        let arr = function (par1, par2, par3) {
            document.write(par1);
            document.write(par2);
            document.write(par3);
        }

        console.log(arr.length);

output:

3


        let arr1 = function ( par1 ) { };
        let arr2 = function ( par1, par2 ) { };
        let arr3 = function ( par1, par2, par3 ) { };
        let arr4 = function ( par1, par2, par3,par4 ) { };

        console.log( arr1.length );
        console.log( arr2.length );
        console.log( arr3.length );
        console.log( arr4.length );

output:

1
2
3
4


Browser Support

Chromeyes
Edgeyes
Firefox1
Internet Exploreryes
Operayes
Safariyes
Android webviewyes
Chrome for Androidyes
Edge mobileyes
Firefox for Android4
Opera Androidyes

1 Comment »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: