Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
-1
rated 0 times [  1] [ 2]  / answers: 1 / hits: 44508  / 13 Years ago, tue, may 31, 2011, 12:00:00
var str = This is a string;
var thing = str.replace(string,thing);

console.log( str )
>> This is a string

console.log( thing )
>> This is a thing


Is there another method I can use, besides replace, that will alter the string in place without giving me a new string object?


More From » string

 Answers
15

No, strings in JavaScript are immutable.


[#91949] Monday, May 30, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jeffn

Total Points: 559
Total Questions: 81
Total Answers: 103

Location: Spain
Member since Thu, Dec 23, 2021
2 Years ago
;