Chrome JavaScript developer console: Is it possible to call console.log() without a newline?

前端 未结 12 855
生来不讨喜
生来不讨喜 2020-11-29 05:07

I\'d like to use console.log() to log messages without appending a new line after each call to console.log(). Is this possible?

12条回答
  •  时光取名叫无心
    2020-11-29 05:25

    You can use a spread operator to display output in the single line. The new feature of javascript ES6. see below example

       for(let i = 1; i<=10; i++){
            let arrData = [];
            for(let j = 1; j<= 10; j++){
                arrData.push(j+"X"+i+"="+(j*i));
            }
            console.log(...arrData);
        }
    

    That will print 1 to 10 table in single line.

提交回复
热议问题