I noticed this "interesting" behaviour. Suppose you have a <div id="editableDiv" contenteditable="true"></div>
and you want to get its value (in this case, assume your value is something like 'hello ' (with a trailing whitespace). Afterwars, you want to convert that string into an array using split():
var string = window.getSelection().anchorNode.data // hello_ (_ means whitespace)
var myArray = string.split(' ') // ['hello '] -> includes whitespace!
However, when you manipulate a string without having to get that value through an editable div, everything works as usual.
Why and how can I force trailing whitespaces to produce another empty value in the resulting array (['hello', ''])
?
Thanks