iterate through interface typescript code example

Example 1: ts iterate over interface properties

class Activity {
    public id: string = '';
    public title: string = '';
    public body: string = '' ;
    public json: Object = {};
}

let activity = new Activity()

const headers: Array<Object> = Object.keys(Activity).map(key => {
    return { text: key, value: key }
});

console.log(JSON.stringify(headers))

Example 2: make an interface iterator typescript

interface Iterable<T> {
    [Symbol.iterator](): Iterator<T>;
}