0

In Node.JS I would like to print a line with tabs as a delimiters,

can someone please explain why it is not printing a tab in the first console.log?

here is a code snippet:

var a = "1233423"
console.log(a + '\t' + a);  // shows 1233423 1233423
console.log(a + 's\t' + a); // shows 1233423s 1233423
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Oleg
  • 601
  • 1
  • 8
  • 14

1 Answers1

2

The console has a tabstop at position 9 The added s makes the console go over it and moves to the next tabstop

See what happens when I add a digit

var a = "12334230"
console.log(a + '\t' + a);  // shows 12334230 1233423
console.log(a + 's\t' + a); // shows 12334230s 1233423

You may want to investigate Node.js formatted console output

mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • what does it mean tabstop at position 9? can i somehow put the tabs unrelated to the tabstops? maybe using file stream? – Oleg Jul 05 '18 at 10:41