Welcome to SomaliNet Forums, a friendly and gigantic Somali centric active community. Login to hide this block

You are currently viewing this page as a guest. By joining our community you will have the ability to post topics, ask questions, educate others, use the advanced search, subscribe to threads and access many, many other features. Registration is quick, simple and absolutely free. Join SomaliNet forums today! Please note that registered members with over 50 posts see no ads whatsoever! Are you new to SomaliNet? These forums with millions of posts are just one section of a much larger site. Just visit the front page and use the top links to explore deep into SomaliNet oasis, Somali singles, Somali business directory, Somali job bank and much more. Click here to login. If you need to reset your password, click here. If you have any problems with the registration process or your account login, please contact us.

MODULE2: Functions IN and OUT

Qaybta Xirfada Sayniska iyo iwm

Moderators: Moderators, Junior Moderators

OUR SPONSOR: LOGIN TO HIDE
User avatar
afisoone
SomaliNet Super
SomaliNet Super
Posts: 5489
Joined: Wed Jul 22, 2009 9:46 pm
Location: We all want to become president even though Amisom controls Mogadishu

MODULE2: Functions IN and OUT

Postby afisoone » Fri Oct 07, 2016 7:17 am

Salaad subax wanaagsan.

Module2 waxaan rabaa inaa ku sharaxo javascript functions.
In Javascript, they are two types of functions.

1. Declaration function
2. Expression function
1. Declaration function: You can use the function before it is define. Javascript compiler reads declaration at compile time.

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); }
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

Code: Select all

let waxDaabac=(qoraal)=>{ console.log(qoraal); }; waxDaabac("we use it after we define the 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.

Code: Select all

let xisaabi=(tiro1, tiro2)=>tiro1+tiro2; console.log(xisaabi(5,5));
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.

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....

OUR SPONSOR: LOGIN TO HIDE

Hello, Has your question been answered on this page? We hope yes. If not, you can start a new thread and post your question(s). It is free to join. You can also search our over a million pages (just scroll up and use our site-wide search box) or browse the forums.

  • Similar Topics
    Replies
    Views
    Last post

Return to “Careers - Engineering, Science & Computers”

Who is online

Users browsing this forum: No registered users and 5 guests