TypeScript StringMap

agnusdei·2023년 7월 5일
0
post-custom-banner
const stringMap: Record<string, string> = {
  MASTER: '마스터',
  CONSULTANT: '컨설턴트',
  ETC: '기타',
  ADMIN_PENDING: '승인대기',
  ADMIN_APPROVED: '승인',
  ADMIN_BLOCKED: '차단',
};

console.log(stringMap.MASTER); // Output: "마스터"
console.log(stringMap.CONSULTANT); // Output: "컨설턴트"
console.log(stringMap.ADMIN_APPROVED); // Output: "승인"
// You can access the values by using the corresponding key in the object.

// You can also iterate over the keys and values in the object:
for (const key in stringMap) {
  if (Object.prototype.hasOwnProperty.call(stringMap, key)) {
    const value = stringMap[key];
    console.log(`Key: ${key}, Value: ${value}`);
  }
}
post-custom-banner

0개의 댓글