开发者

Another way to concatenate

开发者 https://www.devze.com 2023-01-07 18:50 出处:网络
Is there another a way to开发者_Go百科 concatenate a \'#\' character like I\'m doing below? radioButtonID = \'#\' + radioButtonID;\"#\".concat(radioButtonID)

Is there another a way to开发者_Go百科 concatenate a '#' character like I'm doing below?

radioButtonID = '#' + radioButtonID;


    "#".concat(radioButtonID)
or
    ["#",radioButtonID].join('')


I suppose you could do something like this:

var radioButtonID = ['#', radioButtonID].join('');


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


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

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


Not very efficient, but this works:

radioButtonID.replace(/(.+)/,"#$1")
0

精彩评论

暂无评论...
验证码 换一张
取 消