Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8691

Node.js: printf風の文字列フォーマットをする方法

$
0
0

Node.jsでprintf風の文字列フォーマットをするには、util.format関数を使うと良い。

const{format}=require('util')constmessage=format('値は %s のうちのどれかにしてください',[1,2,3])console.log(message)//=> 値は [ 1, 2, 3 ] のうちのどれかにしてください

公式ドキュメント: Util | Node.js v13.11.0 Documentation


Viewing all articles
Browse latest Browse all 8691

Trending Articles