I have two scenario in both the case split() behaves differently
1.When we say
var x ="dadasd\n\n\nsdfsfsdf"
var y=x.split('\n')
then value of is y
["dadasd", "", "", "sdfsfsdf"]
but i was expecting y to be
["dadasd", "", "","","sdfsfsdf"]
2.now when we say
var z ="fsdfsfs\n\n\n"
undefined
var a =z.split("\n")
undefined
a
["fsdfsfs", "", "", ""]
This time I am getting expected value why these two scenario has different behavior
Why does split() behaves differently in first case and do we have any function in java script which can give me expected result in my first scenario