Last Updated: October 11, 2018
·
13.89K
· diggabyte

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."