728x90
SMALL
#javascript
#JavaScript/Object/Array.join()/Concatenate array elements into one value
.join()
.join() concatenates the elements of an array into a single value.
grammar
var jbStr1 = jbAry.join();
Makes the elements of the jbAry array one value. Separate elements with a comma (,). To separate elements with a different character, put the desired character inside the ().
var jbStr2 = jbAry.join( ' / ' );
grammar
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JavaScript</title>
</head>
<body>
<script>
var jbAry = [ 'Lorem', 'Ipsum', 'Dolor' ];
var jbStr1 = jbAry.join();
var jbStr2 = jbAry.join( ' / ' );
document.write( '<p>' + jbStr1 + '</p>' );
document.write( '<p>' + jbStr2 + '</p>' );
</script>
</body>
</html>
728x90
LIST