我需要以下函數(shù),當調(diào)用該函數(shù)以返回沒有重復(fù)的元素數(shù)組時const removeDuplicates = nums => { var result = Array.from(new Set(nums)); console.log(result) }removeDuplicates([1,1,2,2,3])基本上,我希望此函數(shù)在沒有console.log 調(diào)用的情況下就可以工作,就像這樣,removeDuplicates([1,1,2,2,3]) 請注意,return在這種情況下,該函數(shù)不起作用,因為它阻止了該函數(shù)的調(diào)用。附言:我已經(jīng)閱讀了很多與我的問題有關(guān)的答案,但是它們并沒有專門回答我的問題。特別是,我想removeDuplicates用提供的元素數(shù)組調(diào)用該函數(shù),就像這樣:removeDuplicates([1,1,2,2,3])我希望它返回沒有重復(fù)的元素。
通過調(diào)用函數(shù)從元素數(shù)組中刪除重復(fù)的值
慕妹3242003
2021-04-13 17:14:13