Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
string concatenation multiple variable by jquery

Here is a line of string:

apple:{0},pear:{1},banana:{2}

I want to raw the variable to the string. Here is my code:

var AllString="apple:{0},pear:{1},banana:{2}";
var apple=0;
var pear=1;
var banana=2;
var NewString=AllString.replace("{0}",apple).replace("{1}",pear).replace("{2}",banana);

In spite it works, it is so troublesome.

I have learned C# before, and C# has a syntax sugar just like this:

var NewString=string.format(AllString,apple,pear,banana);

I am not sure but are there any similarities like this in jquery to make it more convenient? Thank you.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!