Splitting a String into an Array

A very common task with strings is to split them into arrays, using a separator character. For example, the following code splits a time string into an array of its basic parts, using the split() method on the ":" separator:

var t = "12:10:36";var tArr = t.split(":");var hour = tArr[0];var minute = tArr[1];var second = tArr[2];

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.