As the title explains the query
Can somebody please explain the behavior of following two outputs.
"".split(",").length
gives output
1
where as
",".split(",").length
0
In the first case, the original string is returned, because the separator is not found.
From the API docs:
If the expression does not match any part of the input then the resulting array has just one element, namely this string.
2.1m questions
2.1m answers
60 comments
57.0k users