<! DOCTYPEhtml>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,height=device-height">
  <title>Easy concatenation of JS strings using placeholders</title>
  <style>
  </style>
</head>

<body>
  <script>
  let args = ['xu'.'xu']
  let s = '%s , %s'
  let argIndex = 0
  let newString = '%s , %s'.replace(/%s/g.() = > args[argIndex++])
  console.log(s) //%s , %s
  console.log(newString) / / xu, xu
  </script>
</body>

</html>
Copy the code