Why do I see javascript arrays getting created with string.split()?

Posted by Matthew on Stack Overflow See other posts from Stack Overflow or by Matthew
Published on 2010-06-18T12:53:44Z Indexed on 2010/06/18 13:03 UTC
Read the original article Hit count: 162

Filed under:
|
|

I see code like this all over the web

var days= "Monday Tuesday Wednesday Thursday Friday Saturday Sunday".split(" ");

Why do that instead of

var days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about best-practices