[JavaScript] console.log only read this object will be printed at the time of viewing, and show up at the moment the relevant attributes and values

 
/ * * 
   * Write a function to solve console.log only read this object will be printed at the time of viewing, and show up at the moment the relevant attributes and values 
   * @param Arg 
   * / 
  const log = function (... Arg) { 
    arg1 the let = arg.map (Item => {
       IF ( typeof Item === 'Object' ) { 
        the let JSON = the JSON.stringify (Item) 
        the let obj = the JSON.parse (JSON)
         return obj 
      } the else {
         return Item 
      } 
    } ) 
    console.log.apply ( null , arg1) 
  } 
  the let A{A =: [. 1, 2,. 3], B: 2, C: to true , D: 'before' } 
  log ( 'before changing the log:' , A) 
  the console.log ( 'Console before change:' , A) 
  aapush ( 2 ) 
  ab & =. 5 
  AC = to false 
  AD = 'after' 
  log ( : 'after log change' , A) 
  the console.log ( 'console after change:', a)

 

Print value:

 

 

 

A statement: console.log () is an asynchronous method

Argument 2: When printing a target, because of the value of the object is the value of the memory references, so it will exist when the object of printing, when referring to the value of the object when the value of the object has occurred changed. So read this object will only be printed when viewing, and show up at the moment the relevant attributes and values.

Value below was evaluated just now explain the expected value is the current time

Guess you like

Origin www.cnblogs.com/frost-yen/p/11613414.html