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…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

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.