Placeholder replacementConsole printing (conlose.log()) or splicing character replacement can be solved with the help of placeholders
Example code: // %s Example let s1 = 'love' let s2 = 'Motherland' console.log('001--I%s my%s', s1, s2) // -> I love my motherland // %f and %i, %d examples/* It is recommended to use %f, both integers and decimals are OK. %d can only output integers, and decimals will be ignored directly*/ let n1 = 100 let n2 = 5.8 console.log('002--I'm %d points away from %d points', n1, n2) // -> I'm 5 points away from 100 pointsconsole.log('002--I'm %i points away from %i points', n1, n2) // -> I'm 5 points away from 100 pointsconsole.log('003--I'm %f points away from %f points', n1, n2) // -> I'm 5.8 points away from 100 points// %oExamplelet o = { name: 'Kakashi', age: 25 } console.log('004--The information of the ninja performing the mission is %o', o) // -> The information of the ninja performing the mission is {name: "Kakashi", age: 25} //%c example var str = '005--I am a %c example' let st = 'color: #000; background-color: orange; padding: 5px;);' console.log(str, st) console.log( '006--%c---------------I am a separator-----------------', 'color:red;font-size:10px' ) ript> Console Printing Printing in the browser is not limited to This section only lists the methods that I think are commonly used. table()The console.table method can convert composite data into a table for display. let o = { username: "kakashi", age: 25, Skill:['Chidori', 'Earth Flow Wall', 'Sharingan'] } console.table(o); log, info, warn, errorconsole.log('001--I am a normal output statement'); console.info('002--I am a normal information output statement'); console.warn('003--I am a warning output statement'); console.error('004--I am an error output statement'); group(), groupCollapsed(), groupend() console.group('First round of output') console.log('I am the first round of output statement 1') console.log('I am the first round of output statement 2') console.log('I am the first round of output statement 3') console.log('I am the first round of output statement 3') console.groupEnd() console.groupCollapsed('First round of output') console.log('1 is output again') console.log('2 is output again') console.log('Another 3 is going to be output') console.groupEnd() console.log('last output') The above is the detailed content of the web string concatenation placeholder and conlose object API. For more information about web string placeholders and conlose object API, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: How to implement Nginx reverse proxy and load balancing (based on Linux)
>>: MySQL character set viewing and modification tutorial
Table of contents Preface 1. How to write functio...
1. Download the mysql tar file: https://dev.mysql...
Most of this article refers to other tutorials on...
Create a database Right click - Create a new data...
Table of contents 1. How to represent the current...
Don’t introduce a front-end UI framework unless i...
You can use the attribute in HTML5 <input="...
Table of contents Preface 1. JDBC timeout setting...
Optimizing large amounts of database data is a hu...
The current environment is: Centos 7.5 docker-ce ...
<br />This article will briefly introduce yo...
1. First download from the official website of My...
Table of contents 1. Introduction 2. Install Dock...
The previous article was a simple review of the B...
So we introduce an embedding framework to solve th...