tags:

views:

80

answers:

5

Is there another a way to concatenate a '#' character like I'm doing below?

radioButtonID = '#' + radioButtonID;

+2  A: 

That's about as short as it could get if you are prefixing.

meder
A: 

What's wrong with what you've got there? That should work.

Unless you're looking for a stringbuffer or something...

Jivlain
Nothing just wondered if there was a shorter way basically in JS, cause I did not find one.
CoffeeAddict
+3  A: 

I suppose you could do something like this:

var radioButtonID = ['#', radioButtonID].join('');
Ryan Kinal
Nice. It's like Javascript calisthenics.
Peter Ajtai
A: 

Not very efficient, but this works:

radioButtonID.replace(/(.+)/,"#$1")
Gert G
+3  A: 
    "#".concat(radioButtonID)
or
    ["#",radioButtonID].join('')
Jet
why do you have to use " as opposed to 2 ' ?
CoffeeAddict
You don't single and double quotes are usually interchangeable.
Pullets Forever