Beautiful log in javascript
Simple tip for enhance your javascript console:
String substitution and formatting
%s Formats the value as a string.
%d Formats the value as an integer.
%i Formats the value as an integer too.
%f Formats the object as a floating point value.
%o Formats the value as an expandable DOM element (as in the Elements panel).
%O Formats the value as an expandable JavaScript object.
%c Applies CSS style rules to output string specified by the second parameter.
a real example:
console.log('SENT URL: %c %s >>>>>> %c | HTTP Method: %c"%s" %c| PARAMS: %O', "color: green; font-size: 12px", requestOpts.url, "color: black;", "color: #BA49FF; font-weight: bold; font-size: 12px", requestOpts.method, "color: black;", requestOpts.data);Written by Marcio Gasparotto
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Console
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#