SOS

In javascript,can the for in statement loop over all of the property names in an object,including functions and prototype properties ????

解决方案 »

  1.   

    In javascript,can the for in statement loop over all of the property names in an object,including functions and prototype properties 在JavaScript中,可以在一份声明中循环,在超过一个对象的属性名称,包括职能和原型的所有属性应该是在一个类中有方法和属性。其实还是面象对象的原则。
      

  2.   

    哈哈~
    其实是想知道,这么个对象var user = {
    name : "ZhangSan",
    password : "123456",
    address : {
    city : "ShangHai",
    street : "WenShui Road"
    }
    }在这种情况下var myvar
    for (myvar in user){
    document.writeln(myvar+" : "+user[myvar]);
    }myvar会拿到原型中的属性么?
    JavaScript: The Good Parts这本书中说会,我试的结果是不会.
      

  3.   


    function array_max( ){
       var i, max = this[0];
       for (i = 1; i < this.length; i++)
       {
       if (max < this[i])
       max = this[i];
       }
       return max;
    }
    Array.prototype.max = array_max;var user = [1, 2, 3];var myvar 
    for (myvar in user){ 
      document.writeln(myvar + " : " + user[myvar]); 

      

  4.   

    can the for 这是什么意思?
      

  5.   

    javascript对象中的原生属性和方法肯定拿不到了。
    比如 Array.length Array.join()
      

  6.   


    the for in statement  --- for in语句