Q:

Array Split null value counting 1 in javascript

Javascript array lengh giving 1 if null.I am using Split function.
var str = '';
var arr = str.split(',');
alert(arr.length);
**Output:1**

When there is any value in string counting correctly
  var str = 'a,b,c';
  var arr = str.split(',');
  alert(arr.length);
  ****Output:3****

A:

An empty string isn't a null value. And String.prototype.split splits a string into array indexes when it finds the separator character. In your empty string, there's a single string. Therefore, you get an array length of 1.

