In all programming languages the use of methods is essential for the development of activities, with them you can reuse blocks of code throughout the project so that it is much easier to process or have return of certain information.

In Javascript, methods are called functions and are created using syntax function().

FUNCTION WITHOUT RETURN

This type of function is declared to perform a given code block. Finished processing, the code continues to run again within the logic implemented.

<SCRIPT LANGUAGE=”javaScript” type=”text/javaScript”>
function hello() {
document.write (“Welcome.”);
}
</ SCRIPT>

FUNCTION WITH RETURN

This type of function returns a value from the source code implemented. This value is often used in another process, to return the information to return syntax is used, check out the example below:

<SCRIPT LANGUAGE=”JavaScript” TYPE=”text/javascript”>
function sum() {
return 10+5;
}

document.write (“10 + 5 = ” + soma() );
</SCRIPT>

FUNCTION WITH PARAMETERS

These functions are used when you need to process certain information from a variable informed by the developer.

<SCRIPT LANGUAGE=”JavaScript” TYPE=”text/javascript”>
function mostrar (msg){
document.write (msg);
}

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

var resultado;
mostrar (” 20 + 30 =“);
result = sum(20, 30);
show(result);
</SCRIPT>

javascript

All formats functions are used in everyday life of a programmer at all is because of this pattern that we can work any kind of logic programming.

Want to test our examples and learn more about one of the tools of development the fastest growing market? Then download the free version already Scriptcase and start today to enjoy all the benefits of our tool.

You might also like…

How to implement A2F using Own Development in NodeJS in a Scriptcase application

A2F using Own Development in NodeJS A2F: In a previous article, we talked about Swivel as an extern...

Specialists or generalists, who gets a better advantage by using Scriptcase?

Hey there! Today  we will figure what are the ideal profiles for those who wish to take advantage o...

Disabling autofill and autocomplete Chrome browser in login screens

Hello, here I want to show an alternative to disable the autofill and autocomplete of the chrome bro...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.