A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/Function below:

Function · WebPlatform Docs

Function Summary

Creates a new function.

Syntax
function functionName ( [ argname1  [, ...[, argnameN ] ] ] )

functionName = new Function( [ argname1 ,  [... argnameN ,] ] body );
functionName
Required. The name of the newly created function
argname1…argnameN
Optional. A list of arguments the function accepts.
parameters
Optional. Parameters are the named arguments in the function declaration’s arguments list. Parameters must be valid identifiers. If there is more than one, parameters are separated by commas.
body
Optional. A string that contains the block of JavaScript code to be executed when the function is called.
Examples

To declare a function that adds the two arguments passed to it, you can do it in one of two ways:


 function add(x, y)
 {
    return(x + y);
 }


 var add = function(x, y) {
      return(x+y);
 }


 add(2, 3);
Remarks

The function is a basic data type in JavaScript. Syntax 1 creates a function value that JavaScript converts into a Function object when necessary. JavaScript converts Function objects created by Syntax 2 into function values at the time the function is called.

Syntax 1 is the standard way to create new functions in JavaScript. Syntax 2 is an alternative form used to create function objects explicitly.

Note – When you call a function, make sure that you always include the parentheses and any required arguments. Calling a function without parentheses causes the function itself to be returned, instead of the return value of the function.

Properties

prototype Property

Methods

valueOf Method

See also Other articles Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4