[JS] console.log () to print out the colorful black

Be careful not visit B station to the F12, Ever see a small blue-screen TV, and thus understand what

Generally speaking first about the syntax:

console.log('%c巴拉%c巴拉','color:#fff','color:#000');

// This code 
first parameter% 1 c is a parameter two alternate style represented;
Parameter 1 second alternate style% c is a parameter represented by 3;
...
(font color, background color, font size are possible, others to discover)

// The above is equivalent to the wording

console.log(console,['%c巴拉%c巴拉','color:#fff','color:#000']);

Theme: colorful print black

//创建新数组,存放数据及样式
arr=[''];
for(var x = 1; x<10;x++){
    //给每一个黑字设置样式
    arr[0]+='%c黑';
    //用随机函数生成三位数代表rgb颜色
    arr[x]='color:#fff;font-size:50px;background-color:#'+Math.random().toFixed(3)*1000;
}
console.log.apply(console,arr)

effect

 

This time, someone asked, what is the use? I am responsible to tell you, no, what, what, eggs, use.

 

 

Published 35 original articles · won praise 18 · views 370 000 +

Guess you like

Origin blog.csdn.net/TXX_c/article/details/83622139