JS basic grammar --- String objects

String ----> is an object

  • String can be seen as an array of characters, but there is no character type js
  • A is a character, the character in the other languages ​​with a pair of single quotes
  • Js string may be used in single quotes may be used double quotes
  • Because the string can be seen as an array, it can be traversed by a for loop

 

String characteristics: immutable, the string value is not changed

The reason why the value of the string appears to be changing, it is because the point has changed, not really value changed

        var str = "123";
        str = "456";
        console.log(str);//456

 

        var STR = "Hello" ; 
        STR [ . 1] = "W is";   // string can not be changed by the index value to access a string 
        // however, is only accessible --- --- read read

 

        var str = "small Su wretched good" ; 
        str = "Little Su good evil"; // reassigned 
        console.log (str);

 

 

Guess you like

Origin www.cnblogs.com/jane-panyiyun/p/11975959.html