JavaScript console.log: native string substitution with %s
Description
String substitution tokens, "%s", can be used in console.log, console.info, console.debug, console.warn and console.error. Simply append an argument for each token present in the message:
Browser Support
- Firefox (w/ Firebug)
- Chrome
- WebKit
Example
console.log("Hello %s", 'world!');
// "Hello world!"
console.log("Hi %s, my name is %s", 'world', 'Joe',);
// "Hi world, my name is Joe."
Written by diggabyte
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#