2/27/2024 0 Comments Npm output ansi escape sequencesThere are two ways to style console messages in DevTools. The %i indicates that the value should/will be converted to an integer, but the argument is a string.The command above produces Jane has NaN kiwis. ![]() Here is an example of what happens if the type conversion is invalid.Ĭonsole.log('Jane has %i kiwis.', 'two') ![]() The %d indicates that the value should/will be converted to an integer. Instead of logging 3.5 oranges, the output is 3 oranges.The command above produces I have 2 apples and 3 oranges.The output message will be converted according to the format specifier.Ĭonsole.log('I have %i apples and %d oranges.', 2, 3.5) The command above produces The total weight of 3 apples and 2 oranges is 432.4 grams.You can use more than one format specifier in a message.Ĭ('The total weight of %i %s and %d %s is %f grams.', 3, 'apples', 2, 'oranges', 432.4) Specifierįormats the value as a floating point valueįormats the value as an expandable DOM elementįormats the value as an expandable JavaScript objectĪpplies CSS style rules to the output string as specified by the second parameter Here is the list of format specifiers Chrome DevTools support currently. The command above produces Chrome DevTools is awesome.You can use the format specifiers to format the console messages.įormat specifiers begin with a percent character (%) and terminate with a "type character" which indicates the type of data (integer, float, etc.). This guide assumes that you understand the fundamentals of web development, such as how to use JavaScript to add interactivity to a page. See Get Started With Logging Messages to learn how to log messages to the Console. This guide shows you how to format and style messages in the Chrome DevTools Console.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |