Home  >  Q&A  >  body text

javascript - js string data type, what does this expression mean?

JS string data type, what does this expression mean? Didn't understand much.

迷茫迷茫2667 days ago711

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-06-30 09:54:31

    • First of all, there is a typo, it should be "雷一" should be "another", and "wear piece" should be "create".

    • He was not very clear when describing this paragraph. In fact, all his descriptions here are based on the memory space, that is to say:

      • In JS, the memory space of a string cannot be modified directly once it is created. If you need to change the value of a variable, you must first destroy the originally allocated memory space, reallocate the memory space and fill it with a new value.

      • So, his explanation of the code refers to var lang = 'java'This creates a string value, and the memory space corresponding to this value cannot be changed, lang = lang + 'script'When the value is reassigned here The operation is:

        • First open up a new memory space of 10 characters

        • Fill the original lang value memory space and the 'script'string memory space correspondingly into this 10-character memory space

        • Destroy the two spaces that originally stored lang and 'script'strings

        • Assign the newly opened and filled space of 10 characters to the variablelang

    • If your understanding is based on the appearance you can see (such as string variables and the like), then you must have been fooled by the author's excessive omissions.

    reply
    0
  • Cancelreply