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 uses the MVC template?

Maybe you might have thought about this at some point, “Scriptcase uses the MVC templates?" Well, ...

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...

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.