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…

Scriptcase & Web Services

This time I will explain how to work with web services inside the Scriptcase, directly with PHP and...

More updates in 9.4 version

Recently version 9.4 was released bringing a new design concept to the generated applications of Sc...

Taking a look at version 9.4

Scriptcase released its version 9.4, and this one brings many interesting news, specially regarding...

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.