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.如传入的数组元素为[123, "meili", "123", "mogu", 123],则输出:[123, "meili", "123", "mogu"] 2.如传入的数组元素为[123, [1, 2, 3], [1, "2", 3], [1, 2, 3], "meili"],则输出:[123, [1, 2, 3], [1, "2", 3], "meili"] 3.如传入的数组元素为[123, {a: 1}, {a: {b: 1}}, {a: "1"}, {a: {b: 1}}, "meili"],则输出:[123, {a: 1}, {a: {b: 1}}, {a: "1"}, "meili"]
The text was updated successfully, but these errors were encountered:
// 判断对象 function isObj(obj){ return Object.prototype.toString.call(obj) === '[object Object]' } // 对象重整 对key进行排序 function parseObj(obj){ let keys = Object.keys(obj).sort() let newObj = {} for(let key of keys){ // 不晓得有没有有必要,反正把value为obj的情况也处理一下 - - obj[key]=isObj(obj[key])?parseObj(obj[key]):obj[key] newObj[key] = obj[key] } return newObj } // 最后 const arr = [1,'1',{a:1,b:"1"},{b:'1',a:1},{a:1,b:2},[1,2,3],null,undefined,undefined] function passArr(arr){ return [...new Set(arr.map(item=> isObj(item)? JSON.stringify(parseObj(item)) : ( !item ? item : JSON.stringify(item)) ))].map(item=>!item?item : JSON.parse(item)) }
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: