You would probably use your example like this
var newText = "" + $("p").text().split(" ").join(" ") + "";
This will put span tags around all the words in you paragraphs, turning
Test is a demo.
into
Test is a demo.
I do not know what the practical use of this could be.