Reputation: 950
It's the code I'm printing with node:
const m = `[38;5;1;48;5;16m TEST`
console.log(m)
It changes the text color. As you can see `` is a special char I don't understand(It's not being shown by the browser). How does it work?
Is there any alternative for ESC
?
Upvotes: 1
Views: 224
Reputation: 1623
As @puucee already mentions they are terminal control characters. I find it surprising that it says ESC[
in the code as that won't be escaped in normal node. I suspect that maybe your IDE is converting the "true" escape character to ESC
. Node does not support octal escapes (such as \033
), but hexadecimal escapes. That is, you string should usually be like this:
console.log('\x1b[38;5;1;48;5;16m TEST \x1b[0m')
Upvotes: 1
Reputation: 36
These are terminal control characters. They are often used e.g. for coloring the output. Some are non-printable. Backticks ` in your javascript example are called template literals.
Upvotes: 1