
console[c] = function(message)里面的console[c] 是访问属性的意思吗?
(message)来自哪里
function initConsole(){//设置颜色
var Color = {RESET: "\x1b[39;49;00m",Black: "0;01", Blue: "4;01", Cyan: "6;01", Gray: "7;11", "Green": "2;01", Purple: "5;01",Yellow: "3;01", Red: "1;01"}
//设置前置颜色
var LightColor = {RESET: "\x1b[39;49;00m", Black: "0;11", Blue: "4;11", Cyan: "6;11", Gray: "7;01", "Green": "2;11", Purple: "5;11", Red: "1;11", Yellow: "3;11"}
var colorPrefix = '\x1b[3'
var colorSuffix = 'm'
Object.keys(Color).forEach(function(c){//返回Color对象的所有可枚举键值的数组,Color有几个元素就遍历几遍,3个参数,第一个是正在遍历的元素,第2个是索引,第3个是数组
if (c == "RESET") //如果有元素和"RESET"内容相等,就返回下面的内容
return
console[c] = function(message){
console.log(colorPrefix + Color[c] + colorSuffix + message + Color.RESET)
}
console["Light" + c] = function(message){
console.log(colorPrefix + LightColor[c] + colorSuffix + message + Color.RESET)
}
})
}