Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Say what the thing is
  2. interface MyThingy {
  3.   [key: string]: string|number|Date
  4. }
  5. // Include that when declaring the variable
  6. var datasource: MyThingy[] = [
  7.   { name: 'x', age: 20, address: 'yyyy' },
  8.   { name: 's', age: 30, address: 'zzzz' }
  9. ];
  10.  
  11. let keys: Object[] = Object.keys(datasource[0]);
  12. let dlen: number = datasource.length as number;
  13. while (dlen--) {
  14.     let kLn: number = keys.length;
  15.     while (kLn--) {
  16.         let key: string = keys[kLn] as string;
  17.         let mkey: string | number | Date = datasource[dlen][key] as number;  
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement