2014-10-07

Java and JavaScript String split

There's a big difference between Java and JavaScript version of String's split method/function.

Java

  • "/".split("/") => []
  • "".split("/") => [""]
  • "/something".split("/") => ["", "something"]

JavaScript

  • "/".split("/") => ["", ""]
  • "".split("/") => [""]
  • "/something".split("/") => ["", "something"]

Inga kommentarer:

Skicka en kommentar