JavaScript – Function
1
Function - Definition
2
Function - Definition
3
Function Definition - Syntax
{
//some code(Javascript statements)
}
4
Function Definition
by commas.
{ }.
5
Function Definition - Syntax
A function with no parameters must include the parentheses () after the function name.
Do not forget about the importance of capitals in JavaScript! The word function must be written in lowercase letters, otherwise a JavaScript error occurs! Also note that you must call a function with the exact same capitals as in the function name.�
6
Function Definition
The return Statement:
7
Function calling
<function name>(value1,value2….valueN)
8
Example - Function Definition and calling
9
Example - Function Definition with arguments and calling
10
Example - Function Definition with arguments and return statement
11
JavaScript – Predefined function
12
eval function
syntax:
eval(expr)
where expr is a string to be evaluated.
13
isFinite function
isFinite(number)
where number is the number to evaluate.
if(isFinite(ClientInput) == true)
{
/* take specific steps */ }
14
isNaN function
isNaN(testValue)
15
parseInt function
parseInt(str)
Note : If the first letter is a character in the given string it returns “NaN” value.
16
parseFloat function
parseFloat(str)
Note : If the first letter is a character in the given string it returns “NaN” value.
17
escape function
18
escape function
19
unescape function
20
Number function
21
String function
22