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
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#