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
将数组 [1,1,'true','true',true,true,15,15,false,false, undefined,undefined, null,null, NaN, NaN,'NaN', 0, 0, 'a', 'a',{},{}] 进行去重,去重结果为 [1, 'true', true,15,false, undefined, null, NaN, 'NaN', 0, 'a',{}]
[1,1,'true','true',true,true,15,15,false,false, undefined,undefined, null,null, NaN, NaN,'NaN', 0, 0, 'a', 'a',{},{}]
[1, 'true', true,15,false, undefined, null, NaN, 'NaN', 0, 'a',{}]
题目有点小变态,使用常规的简单去重方法应该是搞不赢。
The text was updated successfully, but these errors were encountered:
方法一:
function unique (arr) { return [ ...new Set(arr) ] }
缺点:对象{}无法去重。
{}
Sorry, something went wrong.
function unique (arr) { var obj = {} return arr.filter(item => { return obj.hasOwnProperty(typeof item + item) ? false : obj[typeof item + item] = true }) }
No branches or pull requests
题目有点小变态,使用常规的简单去重方法应该是搞不赢。
The text was updated successfully, but these errors were encountered: