We’ve talked here on the blog about arrays in JavaScript and how to work with them to create and manipulate the data in an array tasks are really simple but the language provides other means to further facilitate the life of programmers. JOIN and CONCAT methods are great examples of this, and we know a little more about them in sequence.

JOIN

This method is used when you want to join an array into a single string using a separator character, check out the example below:

<script language=”JavaScript” type=”text/javascript”>
var num = new Array (3);
num[0] = 10;
num[1] = 20;
num[2] = 30;
document.write (num.join(“/”));
</script>

What will be printed to the screen from the code shown in the example is “10/20/30”, this way you can create a single string with all the data separated by the character entered.

CONCAT

This method is used to join two or more arrays into one, as shown below:

<script language=”JavaScript” type=”text/javascript”>
var Text1= new Array (“1″, “2″, “3″);
var Text2 = new Array (“4″, “5″, “6″);

var uni = Texto1.concat(Texto2);
document.write (uni);
</script>

he result to be displayed on the screen will be “1,2,3,4,5,6”.

javascript

The practical use of each of these methods will vary according to the logic that will be applied, so well understand how they work can help solve a problem eminent.

Test this and other code in Javascript Scriptcase enjoy and also test the various features our tool to be releasing, do not waste time and download now the free version of our tool and enjoy.

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.