Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see the tab eol spaces in chrome console?

I receive some data after a jQuery $.get and I would like to be able to see all the non visible characters like spaces, tabs, end of line or new line. Is it possible to see this in chrome console? How?

like image 987
user2040597 Avatar asked Mar 01 '14 01:03

user2040597


People also ask

How do I view chrome console history?

Console Logs in Chrome: In Google Chrome, the Console Logs are available as a part of Chrome Dev Tools. To open the dedicated Console panel, either: Press Ctrl + Shift + J (Windows / Linux) or Cmd + Opt + J (Mac).

How do I clear the Inspect Element console?

Use the short cut Ctrl + L to clear the console. Use the clear log button on the top left corner of the chrome dev tools console to clear the console.

How do you clear the console in HTML?

The clear() method clears the console. The clear() method also write "Console was cleared" in the console.


2 Answers

One way would be to a manual replace for all possible whitespace characters:

var html = '\n\t';
console.log(html); // displays whitespace
console.log(html.replace(/\n/g,'\\n').replace(/\t/,'\\t')); // displays '\n\t'

Quite tedious, I know.

like image 103
Arman Bimatov Avatar answered Sep 22 '22 09:09

Arman Bimatov


You can also use JSON.stringify

const data = 'name\tvalue\n'

console.log(JSON.stringify(data))

// "name\tvalue\n"
like image 39
joelnet Avatar answered Sep 18 '22 09:09

joelnet