sh2wag
Last Updated: February 25, 2016
·
3.369K
· diggabyte
0c235779236b6a927e162703798df844

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."
Say Thanks
Respond