# react_ts_test **Repository Path**: crazychad/react_ts_test ## Basic Information - **Project Name**: react_ts_test - **Description**: 试试,一个熟悉代码风格的开始 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-04-27 - **Last Updated**: 2023-04-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 熟悉风格 ## js 的 map 1 写一个函数把[1, 2, 3] 变成 {key1: 1, key2: 2, key3: 3} 2 看看下面的代码, 猜想下这段代码干了什么 ``` const rolePermissionMap = {"role1": ["permission1", "permission2"], "role2": ["permission2", "permission3"]} Array.from( new Set( userInfo?.roleIds?.flatMap((roleId) => { return rolePermissionMap?.[roleId] ?? []; }) ) ) ?? []; ``` 3 redux