728x90
console.log로 출력을 하면
let a = "크래프톤";
let b = "정글";
console.log(a);
console.log(b);
// 출력 :
// 크래프톤
// 정글
console.log를 이용해 출력하면 한 줄씩 출력이 된다.
이는 console.log에 개행 문자가 포함되어 자동으로 줄바꿈이 이뤄지기 때문이다.
하지만 process.stdout.write를 사용해 출력을 하면
let a = "크래프톤";
let b = "정글";
process.stdout.write(a);
process.stdout.write(b);
// 결과 :
// 크래프톤정글
개행 문자가 없는 순수 출력값만 출력하기 때문에 한 줄에 쭉 출력이 이뤄진다.
process.stdout.write(a\n); 이런식으로 개행 문자를 입력해 줄바꿈으로 출력해도 되고 백준 문제를 풀 때는 process.stdout.write가 자유로운 것 같다.
728x90
'짤막한 지식' 카테고리의 다른 글
자바스크립트 출력 시에 뜨는 특수 문자 제거 (1) | 2024.02.27 |
---|---|
Makefile:{line-number}: *** missing separator. Stop. (1) | 2024.02.26 |