إضافة النص إلى بداية السلسلة
-
09-09-2020 - |
سؤال
ما هي أسرع طريقة, لإضافة قيمة جديدة في بداية سلسلة?
المحلول
giveacodicetagpre.
لن يعمل هذا لك؟
نصائح أخرى
منذ السؤال هو حول ما هو أسرع الطريقة ، اعتقدت أنني سأضيف بعض مقاييس الأداء.
ليرة تركية ؛ دكتور الفائز ، بهامش واسع ، هو +
المشغل ، و من فضلك أبدا استخدام التعبير العادي
ES6:
let after = 'something after';
let text = `before text ${after}`;
you could also do it this way
"".concat("x","y")
If you want to use the version of Javascript called ES 2015 (aka ES6) or later, you can use template strings introduced by ES 2015 and recommended by some guidelines (like Airbnb's style guide):
const after = "test";
const mystr = `This is: ${after}`;
Another option would be to use join
var mystr = "Matayoshi";
mystr = ["Mariano", mystr].join(' ');
You can use
var mystr = "Doe";
mystr = "John " + mystr;
console.log(mystr)
لا تنتمي إلى StackOverflow