Format the output of console log for readability #javascript #tips #shorts



Format the output of console log for readability #javascript #tips #shorts

Format the output of console log for readability #javascript #tips #shorts

In JavaScript, the % symbol can be used as a placeholder in a console.log string, followed by a token that specifies the type of data that should be inserted into the placeholder.

Here’s a list of some of the other tokens that you can use in console.log strings:

%s Formats the value as a string
%i or %d Formats the value as an integer
%f Formats the value as a floating point value
%o Formats the value as an expandable DOM element
%O Formats the value as an expandable JavaScript object
%c Applies CSS style rules to the output string as specified by the second parameter

You can use these tokens to format the output of console.log messages in a more readable and expressive way.
————————-
linkedIn – https://www.linkedin.com/in/shrideep-ghag/
twitter – https://twitter.com/SHRIDEEPGHAG
youtube – https://www.youtube.com/@Shrideepghag/
————————–
#shorts #interviewquestions #interview #javascript #js #css #console