js的console總結

1.javascript

<!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.html

<!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.java

<!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.spa

 <!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.rest

 <!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>
相關文章
相關標籤/搜索