We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let res = { name: 'lidong', age: 18, sports: 'baseketball' }, obj, arr = ['name']; obj = arr.reduce((p, n) => { if(n in res) { p[n] = res[n] }; return p },{}) console.log(obj); // {name: "lidong"}
计算出一个字符串中每个字符出现的次数
let str = 'hello world'; let obj2 = str.split('').reduce((acc, item) => { acc[item] = (acc[item] || 0) + 1; return acc }, {}); console.log(obj2) // {h: 1, e: 1, l: 3, o: 2, " ": 1, …}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
提取对象的某些属性
计算出一个字符串中每个字符出现的次数
The text was updated successfully, but these errors were encountered: