MODULE2: Functions IN and OUT
Posted: Fri Oct 07, 2016 7:17 am
Salaad subax wanaagsan.
Module2 waxaan rabaa inaa ku sharaxo javascript functions.
Here is an example of declaration function.
2. Expression function: This function javascript compiler read at run time. That means you use expression only after it is defined. Otherwise you will get e error. Also expression function ends with semicolon in the closing bracket.
here is an example of expression function
As you can see the expression function has started with variable and it has fat arrow. The fat arrow means it will do something the value in the parenthesis.
Those are the only two type of function in javascript...
let's do more example on the expressions.
You can use two parameters... here is an example of expression function with two parameters.
It will give us `10 after it calculates...
If you want to use more than one line. Always use curly braces to keep them together.. here is an example.
That is all about javascript function.
Now here is the full page.
Ok. That is the module 2..
Macalin Afisoone....
Module2 waxaan rabaa inaa ku sharaxo javascript functions.
1. Declaration function: You can use the function before it is define. Javascript compiler reads declaration at compile time.In Javascript, they are two types of functions.
1. Declaration function
2. Expression function
Here is an example of declaration function.
Code: Select all
waxQor("we use here before the function is define");
function waxQor(qoraal)
{
console.log(qoraal);
}
here is an example of expression function
Code: Select all
let waxDaabac=(qoraal)=>{
console.log(qoraal);
};
waxDaabac("we use it after we define the function");
Those are the only two type of function in javascript...
let's do more example on the expressions.
You can use two parameters... here is an example of expression function with two parameters.
Code: Select all
let xisaabi=(tiro1, tiro2)=>tiro1+tiro2;
console.log(xisaabi(5,5));
If you want to use more than one line. Always use curly braces to keep them together.. here is an example.
Code: Select all
let xisaabiAndDaabac=(tiro1, tiro2)=>
{
let total=tiro1*tiro2;
console.log(total);
}
xisaabiAndDaabac(5,5);
That is all about javascript function.
Now here is the full page.
Code: Select all
<!doctype html>
<html>
<meta charset="utf-8">
<head>
<title>Isticmaalka variableka let</title>
</head>
<body>
<script type="text/javascript">
waxQor("we use here before the function is define");
function waxQor(qoraal)
{
console.log(qoraal);
}
let waxDaabac=(qoraal)=>{
console.log(qoraal);
};
waxDaabac("we use it after we define the function");
let xisaabi=(tiro1, tiro2)=>tiro1+tiro2;
console.log(xisaabi(5,5));
let xisaabiAndDaabac=(tiro1, tiro2)=>
{
let total=tiro1*tiro2;
console.log(total);
}
xisaabiAndDaabac(5,5);
</script>
</body>
</html>
Ok. That is the module 2..
Macalin Afisoone....