欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

console.log的輸出語(yǔ)句如何使用

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

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

1.當(dāng)console.log的括號(hào)里

只有'hello'或者"hello"的時(shí)候,引號(hào)里的內(nèi)容原樣輸出

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

2.當(dāng)console.log的括號(hào)里

是'hello"world"'或者"world'hello'"的時(shí)候,引號(hào)里包括的不是相同的引號(hào)也能原樣輸出。

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

3.當(dāng)console.log的括號(hào)里

是'hello'world''或者"world"hello""的時(shí)候,引號(hào)里包括的是相同的引號(hào)需要加 “\”來(lái)轉(zhuǎn)義。

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

4.當(dāng)需要兩個(gè)內(nèi)容之間需要右斜杠時(shí)

“\\”可以輸出一個(gè)右斜杠。

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

5. 當(dāng)需要兩個(gè)內(nèi)容之間需要換行時(shí)

在字符串之間加“\n”,如果直接打回車的話,會(huì)報(bào)錯(cuò)。

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

6.給字符串設(shè)置樣式

用“%c”。

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

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論