亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

console.log的輸出語句如何使用

 更新時間:2024年02月06日 08:56:32   作者:辛憐  
這篇文章主要介紹了關于console.log的輸出語句如何使用問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

console.log()[控制臺的日志]

1.當console.log的括號里

只有'hello'或者"hello"的時候,引號里的內容原樣輸出

<script>
     console.log('hello');
     console.log("world");
</script>

2.當console.log的括號里

是'hello"world"'或者"world'hello'"的時候,引號里包括的不是相同的引號也能原樣輸出。

<script>
     console.log('hello"world"');
     console.log("world'hello'");
</script>

3.當console.log的括號里

是'hello'world''或者"world"hello""的時候,引號里包括的是相同的引號需要加 “\”來轉義。

<script>
   console.log('hello\'world\'');
   console.log("world\"hello\"");
</script>

4.當需要兩個內容之間需要右斜杠時

“\\”可以輸出一個右斜杠。

<script>
   console.log('world\\\\hello');
</script>

5. 當需要兩個內容之間需要換行時

在字符串之間加“\n”,如果直接打回車的話,會報錯。

<script>
   console.log('hello\n\n\nworld');
</script>

6.給字符串設置樣式

用“%c”。

<script>
    console.log('%chello%cworld','color:red;','color:orange');
</script>?

總結

以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論