1.

Why do we use pageYOffset property in JavaScript?

Answer»

JavaScript provides a join() method to join the elements of an array. While joining, you can set the separator as WELL:

array.join(separator)

Here, separator is the resultant array would be specified by this separator. Comma is the default separator.

The return value is the strings as array elements separated by the separator.

Let us see an EXAMPLE wherein we have the following array:

var products = ["Shoes", "Cap", "TShirt", "Shirt", "Trousers"];

The example to convert array into comma-separated list: 

<!DOCTYPE HTML> <html> <body> <script>     var products = ["Shoes", "Cap", "TShirt", "Shirt", "Trousers"];     document.write(products.join()); </script> </body> </html>

The following is the OUTPUT:

Shoes,Cap,TShirt,Shirt,Trousers


Discussion

No Comment Found