Creating a Tab-Separated String from an Array

var weekdays= ["Mon", "Tue", "Wed", "thur", "Fri"] var weekStr = weekdays.join("\t"); // weekStr = "Mon\tTue\tWed\tthur\tFri"

The .join(separator) method allows you to combine an array into a string. The optional separator argument specifies the character or string to place between each item in the newly created string.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.