MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/nc6i5j/remove_duplicate_value_from_array/gy4jvp3/?context=9999
r/learnjavascript • u/suprabha-supi • May 14 '21
89 comments sorted by
View all comments
20
Does this perform better than filter()?
2 u/47milliondollars May 14 '21 Would filter even work? Or do you have to use reduce to check if the value exists yet in an accumulator? 7 u/space_scarab May 14 '21 arr.filter((el, index) => { return arr.indexOf(el) === index; }); 3 u/learning_account_01 May 14 '21 Man. I wish i can think like this. How do you do ? I was stuck at this smilar knida problem (find if array contains duplicate value or not and just return true or false.) and it never clicked me. 4 u/StoneCypher May 14 '21 Man. I wish i can think like this. How do you doit's the accepted answer from the first result on googling "javascript unique"https://stackoverflow.com/a/14438954/763127it's pretty standard in the javascript community 4 u/learning_account_01 May 14 '21 Oh that shows how noob I am. I have lot to learn indeed. Thanks. 2 u/47milliondollars May 14 '21 Don't worry fren, a huge part of coding is googling stuff, you're not expected to think up this shit on your own :) 2 u/learning_account_01 May 14 '21 you're not expected to think up this shit on your ownWell thank god otherwise I can't even dare to dream of becoming a programmer some day.
2
Would filter even work? Or do you have to use reduce to check if the value exists yet in an accumulator?
7 u/space_scarab May 14 '21 arr.filter((el, index) => { return arr.indexOf(el) === index; }); 3 u/learning_account_01 May 14 '21 Man. I wish i can think like this. How do you do ? I was stuck at this smilar knida problem (find if array contains duplicate value or not and just return true or false.) and it never clicked me. 4 u/StoneCypher May 14 '21 Man. I wish i can think like this. How do you doit's the accepted answer from the first result on googling "javascript unique"https://stackoverflow.com/a/14438954/763127it's pretty standard in the javascript community 4 u/learning_account_01 May 14 '21 Oh that shows how noob I am. I have lot to learn indeed. Thanks. 2 u/47milliondollars May 14 '21 Don't worry fren, a huge part of coding is googling stuff, you're not expected to think up this shit on your own :) 2 u/learning_account_01 May 14 '21 you're not expected to think up this shit on your ownWell thank god otherwise I can't even dare to dream of becoming a programmer some day.
7
arr.filter((el, index) => { return arr.indexOf(el) === index; });
3 u/learning_account_01 May 14 '21 Man. I wish i can think like this. How do you do ? I was stuck at this smilar knida problem (find if array contains duplicate value or not and just return true or false.) and it never clicked me. 4 u/StoneCypher May 14 '21 Man. I wish i can think like this. How do you doit's the accepted answer from the first result on googling "javascript unique"https://stackoverflow.com/a/14438954/763127it's pretty standard in the javascript community 4 u/learning_account_01 May 14 '21 Oh that shows how noob I am. I have lot to learn indeed. Thanks. 2 u/47milliondollars May 14 '21 Don't worry fren, a huge part of coding is googling stuff, you're not expected to think up this shit on your own :) 2 u/learning_account_01 May 14 '21 you're not expected to think up this shit on your ownWell thank god otherwise I can't even dare to dream of becoming a programmer some day.
3
Man. I wish i can think like this. How do you do ? I was stuck at this smilar knida problem (find if array contains duplicate value or not and just return true or false.) and it never clicked me.
4 u/StoneCypher May 14 '21 Man. I wish i can think like this. How do you doit's the accepted answer from the first result on googling "javascript unique"https://stackoverflow.com/a/14438954/763127it's pretty standard in the javascript community 4 u/learning_account_01 May 14 '21 Oh that shows how noob I am. I have lot to learn indeed. Thanks. 2 u/47milliondollars May 14 '21 Don't worry fren, a huge part of coding is googling stuff, you're not expected to think up this shit on your own :) 2 u/learning_account_01 May 14 '21 you're not expected to think up this shit on your ownWell thank god otherwise I can't even dare to dream of becoming a programmer some day.
4
Man. I wish i can think like this. How do you do
it's the accepted answer from the first result on googling "javascript unique"
https://stackoverflow.com/a/14438954/763127
it's pretty standard in the javascript community
4 u/learning_account_01 May 14 '21 Oh that shows how noob I am. I have lot to learn indeed. Thanks. 2 u/47milliondollars May 14 '21 Don't worry fren, a huge part of coding is googling stuff, you're not expected to think up this shit on your own :) 2 u/learning_account_01 May 14 '21 you're not expected to think up this shit on your ownWell thank god otherwise I can't even dare to dream of becoming a programmer some day.
Oh that shows how noob I am. I have lot to learn indeed. Thanks.
2 u/47milliondollars May 14 '21 Don't worry fren, a huge part of coding is googling stuff, you're not expected to think up this shit on your own :) 2 u/learning_account_01 May 14 '21 you're not expected to think up this shit on your ownWell thank god otherwise I can't even dare to dream of becoming a programmer some day.
Don't worry fren, a huge part of coding is googling stuff, you're not expected to think up this shit on your own :)
2 u/learning_account_01 May 14 '21 you're not expected to think up this shit on your ownWell thank god otherwise I can't even dare to dream of becoming a programmer some day.
you're not expected to think up this shit on your own
Well thank god otherwise I can't even dare to dream of becoming a programmer some day.
20
u/slowthedataleak May 14 '21
Does this perform better than filter()?