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…

AJAX: What it is and how to use it in Scriptcase

Hello, in this post we will conceptually understand the AJAX event and how use  inside the Scriptca...

What advantages for a company in adopting a low-code tool?

Let's understand how low-code tools have become a facilitator in the web development process as they...

How to implement A2F using Swivel in a Scriptcase application

I want to start talking about Swivel, Swivel is a provider of authentication solutions who have been...

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.