Skip to content

Latest commit

 

History

History
14 lines (12 loc) · 467 Bytes

README.md

File metadata and controls

14 lines (12 loc) · 467 Bytes

TypeScriptの組み込み型関数 Recordの使いどころ

これがもっときれいに書けるんじゃないかと思ってやってみた

const usersAgeFn1 = (users:{[key:string] : {age:number}}) => {
    let ages : {[key:string]:number} = {}
    for( let [key,value] of Object.entries(users) ){
        ages[key] = value.age
    }
    return ages
}

const usersAge1 = usersAgeFn1(users)