js的console总结

1.

<!DOCTYPE html>
<html>
<head>
   <title>format</title>
   <meta charset="gbk">
</head>
<body>
    我爱GH
</body>
<script type="text/javascript">
    console.log("log");
    console.warn("warning");
    console.error("error");
</script>
</html>

2.

<!DOCTYPE html>
<html>
<head>
   <title>format</title>
</head>
<body>
    hello World
</body>
 <script type="text/javascript">
     console.log("身高:%dcm,体重:%fkg",188,44.4);
 </script>
 </html>

3.

<!DOCTYPE html>
<html>
<head>
   <title>分组的使用</title>
</head>
<body>
    hello World
</body>
 <script type="text/javascript">
    console.group("1");
    console.groupEnd();
  console.group("2");
    console.log("2.1:我很丑");
    console.log("2.2:但是我很温柔");
  console.groupEnd();
 </script>
 </html>

4.

<!DOCTYPE html>
<html>
<head>
   <title>类的输出</title>
</head>
<body>
    hello World
</body>
<script type="text/javascript">
    var info = {
        age:20,
        interesting:"mobile programing"
    };
    console.dir(info);
</script>
</html>

5.

<!DOCTYPE html>
<html>
<head>
   <title>html元素的打印</title>
</head>
<body>
<div id="bice">
    <p>我爱程序设计</p>
</div>
</body>
<script type="text/javascript">
       var info = document.getElementById(‘bice‘);
       console.dirxml(info);
</script>
</html>

6.

 <!DOCTYPE html>
<html>
<head>
   <title>assert判断真假</title>
</head>
<body>
<div id="bice">
    <p>我爱程序设计</p>
</div>
</body>
<script type="text/javascript">
    console.assert( 1 ,"结果为假");
    var code = 1024;
    console.assert(year == 2048 ,"code不等");
</script>
</html>

7.

 <!DOCTYPE html>
<html>
<head>
<title>追踪函数</title>
</head>
<body>
<div id="bice">
    <p>我爱程序设计</p>
</div>
</body>
<script type="text/javascript">
  function test(a,b){
        console.trace();
  }
  test(1,1);
</script>
</html>

8.

 <!DOCTYPE html>
<html>
<head>
   <title>计时</title>
</head>
<body>
<div id="bice">
    <p>我爱程序设计</p>
</div>
</body>
<script type="text/javascript">
    console.time("计时开始");
  for(var i=0;i<1000;i++){
    for(var j=0;j<1000;j++){}
  }
  console.timeEnd("计时结束");
</script>
</html>

9.

 <!DOCTYPE html>
<html>
<head>
   <title>性能分析</title>
</head>
<body>
<div id="bice">
    <p>我爱程序设计</p>
</div>
</body>
<script type="text/javascript">
    function Test(){
        alert("性能测试");
       for(var i=0;i<1000;i++){
          for (var i = 0; i < 1000; i++) {
              for (var i = 0; i < 1000; i++) {}
          }
        }
  }
   console.profile(‘性能分析器‘);
    Test();
       console.profileEnd();
</script>
</html>
时间: 2024-08-09 08:48:56

js的console总结的相关文章

js的console你知道多少

js的console你知道多少? 列出所有的console属性 console.dir(console) 或者 console.dirxml(console) 记录代码执行时间 console.time("test"); var count = 0; for(var i=0; i < 10000; i++) { count++; } console.timeEnd("test"); 输出消息格式化 console.log("Hello, %s&quo

js调试console.log使用总结图解

一 实例 打印字符串和对象: 可展开对象查看内部情况: 看一下console对象本身的定义情况: 输出对象情况: utag对象所在文件: 输出对象: 二 Console.log 总结 1 如果你js没到一个境界,我就算教你调试bug,破解一些插件之类的,你也根本不知道我在做什么.我的目的只是让你认识控制台,让你入门调试,之后的路还得靠你们自己走. 不论是 chrome firefox ie(8以上版本) 还是 360急速浏览器 搜狗浏览器 等等,只要按 F12 就能打开控制台. 其实对于这 F1

Node.js API —— console(控制台)

// 说明 Node API 版本为 v0.10.31.    中文参考:http://blog.sina.com.cn/oleoneoy 本段为博主注解. 目录 ● 控制台    ○ console.log([data], [...])    ○ console.info([data], [...])    ○ console.error([data], [...])    ○ console.warn([data], [...])    ○ console.dir(obj)    ○ con

Js 关于console 在IE 下的兼容问题

程序员在开发代码的过程中,使用console作为调试代码过程的一种手段. 发布到测试生产环境,发现IE8 出现加载错误.使用开发者工具调试,发现可以绕过问题. 通过网络搜索和在项目中进行修正. 以下办法均可生效: 1.去除console代码(由于是调试代码,不影响线上使用). 2.在基础Js脚本文件中加入: 1 (function() { 2 var method; 3 var noop = function () {}; 4 var methods = [ 5 'assert', 'clear

js调试工具Console命令详解

一.显示信息的命令 代码如下: <!DOCTYPE html> <html> <head> <title>常用console命令</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <script type="text/ja

js调试工具Console命令详解——转

一.显示信息的命令 <!DOCTYPE html> <html> <head> <title>常用console命令</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <script type="text/javascri

js调试工具console详解

#console基本输出方法,占位符:字符(%s).整数(%d).浮点数(%f)和对象(%o) console.log('日志'); console.info('信息'); console.error('错误'); console.warn('警告'); #console输出分组 console.group('组名'); console.groupEnd(); #对象属性.方法查询 console.dir('对象名称'); #显示某节点上的HTML/XML代码 console.dirxml('节

js中console.log()和console.dir()的区别

console.log(),会在浏览器控制台打印信息 console.dir()可以显示一个对象的所有属性和方法(详细打印,利于分析对象) 原文地址:https://www.cnblogs.com/l-millie/p/10145075.html

js的console.log()

<script type="text/javascript"> console.log(['华为','苹果','小米']); </script> 原文地址:https://www.cnblogs.com/xm666/p/11333318.html