Question:
What can be written inside brackets () in JavaScript function?
Paulinus Pandiangan
2010-05-25 17:48:39 UTC
All JavaScript functions I have ever seen always use this syntax: function_name()

But I haven't seen anything written inside the brackets ().
What can we write into the brackets? Need some explanation. Thanks...
Four answers:
gaiacarra
2010-05-25 18:04:00 UTC
Function parameters, also known as function arguments. It's a concept common to pretty much every programming language.



A function is a piece of code that you give a name so that you can run it any time just by typing in its name, right? Well you can further customize a function by passing parameters to it when you call it. Like say I wanted a function to add numbers together. How could I do that? I can hardly just create a function for all possible number combinations:



function addOneAndOne() { ... }

function addOneAndTwo() { ... }

function addOneAndThree { ... }



...and so on. So instead I create one function and give it two arguments:



function add(firstNumber, secondNumber) {

return firstNumber + secondNumber;

}



So now I can call that function like so:



add(1, 1)

add(1, 2)

add(1, 3)

add(435, 65)



But if the function has no parameters then you're left with empty parentheses.
Sean WebDev
2010-05-25 17:56:23 UTC
Function Parameters are what 'can' be place in the ().



Of course, this assumes that your function needs parameters.



Check out http://www.w3schools.com/js/js_functions.asp for some examples and an explanation
Ratchetr
2010-05-25 18:03:04 UTC
Parameters:

function foo(param)

{

alert(param);

}



function bar()

{

foo("Hello World");

}



Bar will call foo with a string parameter.

foo will display it using alert (which also takes a parameter)

End result: a popup that says Hello World.
2016-10-17 16:16:48 UTC
functionality today_date() { var currentTime = new Date(); var month = currentTime.getMonth() + a million; var day = currentTime.getDate(); var 365 days = currentTime.getFullYear(); rfile.write( day+ "/" + month+ "/" + 365 days); } Then, interior of your td tags:
Loading...