javascript console.log problem
迷茫
迷茫 2017-06-30 09:58:12
0
4
691

1. The console prints an object under chrome debugging. When the object is not expanded, it is displayed as an empty object. After clicking to expand, it is found that there is a value in it. What the hell is this?
2,Picture 1 shows an empty objectwhen it is not expanded,Picture 2 shows a valuewhen it is expanded.

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all (4)
三叔

You printed the empty object first. Between the time you printed it and the time you clicked it, ajax filled the object asynchronously, so there will be a value only when you click it. This is an asynchronous operation, and you cannot use this empty object in advance.

    我想大声告诉你

    When the console is not opened, the console.log is like this

      阿神

      console.log when printing an object. If it is an object, it points to a piece of memory. This memory was empty at first, and then ajax brought data and filled it. It will no longer be empty. console.log you can think of it as responsive

        黄舟

        Since the data displayed in the console will not be updated in real time, the above is just a printed log.

        When you first printObject, it is indeed an empty object.
        But then, the data returned by AJAX populates this object.
        When you expand it, since the expanded display above is data read from the memory, it has value when you click it.

        However, since the above log cannot be retracted or updated after output, theObject{}printed above is still retained.

          Latest Downloads
          More>
          Web Effects
          Website Source Code
          Website Materials
          Front End Template
          About us Disclaimer Sitemap
          php.cn:Public welfare online PHP training,Help PHP learners grow quickly!