[removed] hiding prototype methods in for loop?

后端 未结 6 1771
攒了一身酷
攒了一身酷 2020-12-01 05:14

So lets say I\'ve added some prototype methods to the Array class:



Array.prototype.containsKey = function(obj) {
    for(var key in this)
        if (key =         


        
6条回答
  •  再見小時候
    2020-12-01 05:41

    you could do this:

    for(var key in arr)
    {
       if (typeof(arr[key]) == "function")
          continue;
       alert(key);
    }
    

    But that's a shoddy workaround

提交回复
热议问题