Object properties

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?


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.