Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript add string to start

my code:

var test = "aa";
test += "ee";
alert(test); 

Prints out "aaee"

How can I do the same thing, but add the string not to end, but start: Like this:

var test = "aa";
test = "ee" + test;

This is the long way, but is there somekind of shorter way like in 1st example?

What I want is that I must not write the initial variable out again in definition.

like image 268
Jaanus Avatar asked Oct 19 '25 02:10

Jaanus


1 Answers

There's no built-in operator that allows you to achieve this as in the first example. Also test = "ee" + test; seems pretty self explanatory.

like image 141
Darin Dimitrov Avatar answered Oct 21 '25 18:10

Darin Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!