var html = '\n\t';console.log(html); // displays whitespaceconsole.log(html.replace(/\n/g,'\\n').replace(/\t/,'\\t')); // displays '\n\t'
相当乏味,我知道.