Converting an Array into a String
A very useful feature of Array
objects is the capability to combine the elements of a string to make a String
object, separated by a specific separator using the join()
method. For example, the following code joins the time components back together into the format 12:10:36
:
var timeArr = [12,10,36];var timeStr = timeArr.join(":");
Get Learning AngularJS 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.