Hammer

Consider these two Typescript snippets:

// specimen 1
const KEY_VALUE = {
  'prop-key-1': 'some-prop-value-1',
  'prop-key-2': 'some-prop-value-2'
};

Object.keys(KEY_VALUE).forEach(key => {
  // do something with key and KEY_VALUE[key];
});
// specimen 2
interface KeyValue {
  key: string;
  value: string;
}

const KEY_VALUE: KeyValue[] = [
  {
    key: 'prop-key-1',
    value: 'some-prop-value-1',
  },
  {
    key: 'prop-key-2',
    value: 'some-prope-vale-2'
  }
];


KEY_VALUE.forEach(pair => {
  // do something with pair.key and pair.value
});

Which approach would you rather implement in your project? And why?

Hello world

Welcome to my blog and thanks for passing by. In this blog I will mostly discuss my personal opinion on tech topics and show some of my work.

Feel free to contact me, I like to engage in discussions about interesting subject matters.

I also provide a RSS feed here.