Javascript 权威指南上说:
     When we set out to write the code to perform this experiment, however, we run into a major stumbling block: there is no way to modify the contents of a string. The charAt( ) method returns the character at a given position in a string, but there is no corresponding setCharAt( ) method. This is not an oversight. JavaScript strings are intentionally immutable -- that is, there is no JavaScript syntax, method, or property that allows you to change the characters in a string.  
 replace()
The replace() method is used to replace some characters with some other characters in a string.replace() 难道不是修改string 方法吗?

解决方案 »

  1.   

    replace
    看名字就知道是替换
      

  2.   

    c#中的string,可以直接当数组用,就是说strTemp=“abcdefg”,那么改变其中一位只要strTemp[i]="F"就可以了~~~但是JS中没办法怎么做~~~~上述差不多就这意思~~无法直接改变string中的某位字符~~~replace是属于替换了~
      

  3.   

    String对象不可变的,和Java一样.Immutable
    所以你无法用SetCharat()来修改.
    Replace()其实是创建了一个新的String