js- for in loop only one purpose, traverse the object, the number of circle by the number of control object properties

  

obj = {var
   name: 'Suan',
   Sex: 'MALE',
   Age: 150,
   height: 185,
   characeter: to true
    }
 for (var Key in obj) {
  // the console.log (Key + '' + typeof (Key )) // return key string type
  // console.log (obj.key -> obj [ 'key']); error writing key type string, given the underlying system does not converted into obj [ 'key'] In this case [ 'key'] is quantitative , will be considered to be inside the obj access key attribute
  console.log (obj [key]) // key of type String
        }

Guess you like

Origin www.cnblogs.com/jie-xuan/p/11311172.html