# Object properties

**URL:** <https://forum.ionicframework.com/t/object-properties/151578>\
**Category:** Ionic Framework\
**Created:** [December 28, 2018, 4:54pm UTC](https://forum.ionicframework.com/t/object-properties/151578 "2018-12-28T16:54:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user1111](https://avatars.discourse-cdn.com/v4/letter/u/8baadc/32.png) [@user1111](https://forum.ionicframework.com/u/user1111)\
**Post date:** [December 28, 2018, 4:54pm UTC](https://forum.ionicframework.com/t/object-properties/151578/1 "2018-12-28T16:54:44Z")

</div>

I want to display to template all exists properties of object, but can’t retrieve it:

> import { Device } from ‘@ionic-native/device/ngx’;  
> …  
> constructor(private device: Device,  
> …  
> ngOnInit() {  
> console.log( this.device ); //dislpay as expected: Device cordova, model, etc…  
> console.log( Object.getOwnPropertyNames(this.device) ); //but here Array(0)  
> console.log( Object.keys(this.device) ); // and here Array(0)

}

but this iterations like this, works:

> let result: object = {};  
> for(let v in this.device) {  
> result[v] = this.device[v];  
> }

My question.  
Why calls getOwnPropertyNames, keys return empty data?

![2018-12-28_1854](https://global.discourse-cdn.com/ionicframework/original/3X/6/2/62de06ee3f38cf0e62d9630ac2b40cc377c2e4c1.png)

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [December 28, 2018, 9:13pm UTC](https://forum.ionicframework.com/t/object-properties/151578/2 "2018-12-28T21:13:21Z")

</div>

The answer to “why?” is that JavaScript doesn’t have true OO built into its design, but the larger issue is that you don’t want to do this anyway.

Only interact with objects via their publicly documented properties and methods: never try to poke around in their internals or you will get bit when those internals change.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:03pm UTC](https://forum.ionicframework.com/t/object-properties/151578/3 "2021-07-19T21:03:14Z")

</div>

Closed on July 19, 2021, 9:03pm UTC


