You realize how funny the technology world is when you come upon a technology from 2005 and are immediately distrusting and suspicious that it has already been replaced with something new. “Two years ago!? How antiquated! I’m sure by now we’ve tackled the problem with an extra embedded API added on for ordering triple half-calf mocha skim ole 2% orange juice lattes wearing a bathing suit! … from Emacs!”
You understand my suspicions, I’m sure.
The developer gets all sorts of nifty ways to interact with this data, but the toString function is the sneak-route for abuse. Let’s say we want to construct a multi-line string for some poetry:
Why in the world would you put your HTML inside a CDATA block, you say? For a top secret project, I tell you! The variable htmlFragment now contains this multiline string, since the the “”+ at the beginning caused the subsequent E4X DOM fragment to be cast as a string for concatenation. Test it out for yourself by setting the innerHTML of your page body to the variable above.