Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of js string concatenation placeholder and conlose object Api developed by web

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Web develops the usage of js string concatenation placeholder and conlose object Api. In view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Placeholder replacement

Console printing (conlose.log ()) or splicing character exchange can be solved with the help of placeholders

% s string

% d /% I integer

% f decimal (integer or decimal is fine, recommended)

% o object

The style of the string after% c

Sample code:

/ /% s example let S1 = 'Love' let S2 = 'Motherland' console.log ('001muri-my% sails, S1, S2) / /-> I love my motherland / /% f and% I,% d example / * recommended% f, integer decimal number is no problem% d can only output integers If there is a decimal that will directly ignore * / let N1 = 100let N2 = 5.8console.log ('002color-I am still short of% d', N1, N2) / /-> I am still 5 points short of 100th score console.log ('002color-I am still short of% I score% I score', N1, N2) /-> I am still 5 points away from 100th score console.log ('003fu-I still need% f score', N1 N2) / /-> I am still 5.8points short of the 100th score in the exam. Example let o = {name: 'Kakashi', age: 25} console.log ('004muri-the information of the task ninja is% overns, o) / /-> the information of the mission ninja is {name: "Kakashi" Age: 25} / /% c sample var str = '005Mo-I am a% c example' let st = 'color: # 000 Background-color: orange; padding: 5px;); 'console.log (str, st) console.log (' 006 Musi% c-I am the delimiter -', 'color:red;font-size:10px') ript >

Console print

Conlose.log () is not the only way to print in a browser.

The console object, a native object of JavaScript, provides a variety of ways to interact with the console window

This section only lists what I think are the common methods.

Table ()

Compound type of data, the console.table method can turn it into a table display.

Let o = {username: "Kakashi", age: 25, skill: ['Thousand Birds', 'Earth flow Wall', 'write Wheel eyes']} console.table (o)

Log, info, warn, errorconsole.log ('001muri-I am an ordinary output statement'); console.info ('002murl-I am an ordinary information output statement'); console.warn ('003muri-I am a warning output statement'); console.error ('004muri-I am an error output statement')

Group (), groupCollapsed (), groupend ()

Console.group () and console.groupend () are used to group the displayed information, which is suitable for large amounts of output information.

Console.group () expands the output information of this group by default.

Console.groupend () will put away the output information of this group by default.

Console.group ('first round output') console.log ('I am the first round output statement 1') console.log ('I am the first round output statement 2') console.log ('I am the first round output statement 3') console.log ('I am the first round output statement 3') console.groupEnd () console.groupCollapsed ('first round output') console.log ('I'm going to output 1' again) console.log ('again 2') console.log ('to output 3 'again) console.groupEnd () console.log (' last output')

On the web development of js string concatenation placeholders and the use of conlose object Api answers to share here, I hope the above content can be of some help to you, if you still have a lot of doubts have not been solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report