У меня есть этот проект, в котором я хотел бы объединить объект «функция» (в отличие от объекта JSON - литерал объекта) с существующим объектом. Я хотел бы получить "публично видимые" свойства. однако, когда я делаю цикл для , они не отображаются. они не вызывают console.log()
внутри. как мне их получить?
//obj passed to extend() by external caller
//this is what obj it looked like when i console.log()'ed it
obj = function() {
//skip these private ones
var imPrivate = 'i should not be included';
function imGetter() {}
//i want these guys below:
this.getter = imGetter;
this.imPublic = "i should be included";
}
function extend(obj){
console.log('i can see here');
for (var key in obj) {
console.log('you cannot see here');
}
//...more of our code here
}