Basic JavaScript Question:

Download Job Interview Questions and Answers PDF

How to use "join()" to create a string from an array using JavaScript?

JavaScript Interview Question
JavaScript Interview Question

Answer:

"join" concatenates the array elements with a specified separator between them in JavaScript.

<script type="text/javascript">
var days = ["Sunday","Monday","Tuesday","Wednesday", "Thursday","Friday","Saturday"];
document.write("days:"+days.join(","));
</script>

This produces
days:Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday

Download JavaScript Interview Questions And Answers PDF

Previous QuestionNext Question
How to use strings as array indexes using JavaScript? How to make a array as a stack using JavaScript?