当前位置:网站首页>你所不知道的console
你所不知道的console
2022-06-11 08:24:00 【yyyyan_】
你所不知道的console
学习前端开发时,几乎最先学习的就是 console.log() 。
毕竟多数人的第一行代码都是:console.log("Hello World!") ;
console 对象提供了对于浏览器调试控制台的访问,可以从任何全局对象中访问到console对象。
灵活运用console 对象所提供的的方法,可以让开发变得更简单。
最常见的控制台方法
console.log()-打印内容的通用方法。
console.info()-打印资讯类说明信息。
console.debug()-在控制台打印一条"debug"级别的消息。
console.warn()-打印一个警告信息。
console.error()-打印一条错误信息。

console.log()写css

console.log()使用参数

console.clear()
用于清除控制台信息
console.count(label)
输出count()被调用的次数,可以使用一个参数label。演示如下:
var user = "";
function greet() {
console.count(user);
return "hi " + user;
}
user = "bob";
greet();
user = "alice";
greet();
greet();
console.count("alice");
输出
console.dir()
使用console.dir() 可以打印对象的属性,在控制台中逐级查看对象的详细信息。
console.memory
console.memory 是一个属性,而不是方法,使用memory属性用来检查内存信息。
console.time()和console.timeEnd()
console.time()- 使用输入参数的名称启动计时器。在给定页面上最多可以同时运行10000个计时器。console.timeEnd()- 停止指定的计时器并记录自启动以来经过的时间(以毫秒为单位)。

console.assert()
如果断言为假,将错误信息写入控制台,如果为真,无显示。
console.trace()
console.trace() 方法将堆栈跟踪输出到控制台。
console.table()
在console 中还可以打印表格

打印Html元素

console.group()和console.groupEnd()
在控制台上创建一个新的分组,随后输出到控制台上的内容都会被添加到一个缩进,表示该内容属于当前分组,直到调用console.groupEnd()之后,当前分组结束。
边栏推荐
- 嵌入式软件面试问题总结
- Introduction to database system experiment report answer Experiment 5: database single table query
- torch. Var (), sample variance, parent variance
- 【1】 Integrated learning: quickly understand Integrated Learning
- [software tools] screen recording software captura
- Summary of embedded software interview questions
- Typescript recognizable Union
- TypeScript-null和undefined
- 知识图谱入门之---yedda标注
- How to make hyperlinks in RichTextBox- How can I make a hyperlink work in a RichTextBox?
猜你喜欢

Typescript header file usage details

CentOS essay 03:centos8.2 installing MySQL

【CVPR2022】QueryDet论文精读

Cyclic sort

TRUNC in pytorch_ normal_ principle

Summary of embedded software interview questions

Using flying items to manage by objectives, not being a "headless fly" in the workplace

Use of Excel to XML tool of TestLink

ActiveMQ简单教程,适合初学者,学习笔记yyds

(resolved) the tqdm progress bar in the Jupiter notebook does not update and display in one line, but scrolls down to output
随机推荐
torch. Var (), sample variance, parent variance
TypeScript-在koa中配置TS和使用koa-router
[software tools] screen recording software captura
BFS on tree (tree breathing first search)
嵌入式软件面试问题总结
[programming development] markdown notes tutorial
堆是也可以看成一种树结构,规定根节点必须大于或小于左右子节点,但左右子节点的大小顺序没有规定
Planning tasks for continuous automated testing
Several ways to avoid concurrent modification exceptions of lists
Introduction to database system experiment report answer Experiment 5: database single table query
Is the result too different from the goal? With the help of target management, you can reach the target accurately!
The difference between & & and &
go for it Easily manage all types of items with "flying items"
Using flying items to manage by objectives, not being a "headless fly" in the workplace
DAMENG 数据库登陆
Basic use of typescripy class
Typescript namespace
不想项目失控?你需要用对项目管理工具
Training yolov4 CSP model using coco dataset
TypeScript-可辨识联合