chrome浏览器console命令集合
1. console.assert(expression, object) 根据条件判断,决定是否输出错误消息
2. console.clear()  清理窗⼝
3. unt(label) 计数器
4. console.debug(object [, object, ...]) 等同于debug.log
5. console.dir(object) 使⽤JavaScript对象格式输出object,等同%O
6. console.dirxml(object) 使⽤XML模式输出object,等同%o
7. (object [, object, ...]) 输出错误消息
8. up(object[, object, ...]) 组输出(初始展开)
9. upCollapsed(object[, object, ...])组输出(初始展开)
10. upEnd() 结束组输出
11. console.info(object [, object, ...])等同于debug.log
12. console.log(object [, object, ...])
13. console.profile([label]) JavaScript CPU模拟
14. console.profileEnd()
15. console.time(label) 时间测量
16. console.timeEnd(label) 结束时间测量
17. console.timeStamp([label])
18. ace() 跟踪函数
19. console.warn(object [, object, ...]) 输出警告消息
20. debugger 停⽌执⾏,等同设置断点
log正常输出
error输出错误消息
wran输出警告消息
assert当函数第⼀个参数为假时,输出错误消息(第⼆个参数)
<("Error: %s (%i)", "Server is  not responding",500);
console.warn('Warning! Too few nodes (%d)', a.childNodes.length);
console.assert(list.childNodes.length < 500, "Node count is > 500");
group/groupEnd组输出:把两个函数之间的输出组合为⼀条消息输出出去(最初展开模式)
使⽤groupCollapsed替换group,则最初输出时不展开
var user = "jsmith", authenticated = false;
console.log("Authenticating user '%s'", user);
/
/ authentication
if (!authenticated) {
console.log("User '%s' not authenticated.", user)
}
组输出中可以嵌套
console命令大全var user = "jsmith", authenticated = true, authorized = true;
// Top-level group
if (authenticated) {
console.log("User '%s' was authenticated", user);
/
/ Start nested group
if (authorized) {
console.log("User '%s' was authorized.", user);
}
// End nested group
}
// End top-level group
console.log("A group-less log trace.");
字符串替换符
%s字符串
%d or %i整数
%f浮点数
%o可展开的DOM节点Formats the value as an expandable DOM element (as in the Elements panel). %O可展开的JavaScript对象Formats the value as an expandable JavaScript object.
%c输出时使⽤CSS样式Applies CSS style rules to output string specified by the second parameter. console.log("%cUser %s has %d points", "color:orange; background:blue; font-size: 16pt", userName, userPoints);
time,timeEnd时间测量
console.time("Array initialize");
var array= new Array(1000000);
for (var i = array.length - 1; i >= 0; i--) {
array[i] = new Object();
};
console.timeEnd("Array initialize");

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。