Добавить
Уведомления

How to remove duplicates from an Array using different ways in JavaScript

How to remove duplicates from an Array using different ways in JavaScript My second Channel: WrestleTalkByAzhar - https://www.youtube.com/c/wrestleTalkByAzhar Now you can Donate us via Paypal or Google Pay Paypal link : https://www.paypal.me/Azhar67 GooglePay/PhonePe/BHIM App UPI ID : shaikazharjamal@okhdfcbank Code: let a = [1,2,7,9,2,3,4,5,6,7,6,7,8,9] // 1 st way let b = [] let length = a.length for (let i=0;i(less than)length;i++){ if(!b.includes(a[i])){ b.push(a[i]); } } console.log(b) //2nd way let tempVar a.sort(); for(let i=0;i(less than)length;i++){ if(a[i] !== tempVar){ b.push(a[i]) tempVar = a[i] } } console.log(b) // 3rd way - empty object let x={} for(let i of a){ x[i] = 20 } console.log(x) console.log(Object.keys(x)) //4th way using SET let simpleSet = new Set(a) console.log(simpleSet) console.log(simpleSet.keys()) console.log([...simpleSet]) Description Tags: 5 ways to remove duplicate elements from array in JavaScript | Interview Guide Remove duplicates from array in Javascript | Algorithm Interview Question JavaScript Problem: Removing Duplicate Objects from an Array Chapters 4 easy ways to remove duplicate elements from Array - JavaScript JavaScript Interview #11: Program to Remove Duplicate Values from Array in JavaScript JavaScript How To Remove An Item From Array Tutorial Chapters: 0:00 - Introduction 0:27 - Remove duplicates First way using Includes method 4:17 - Remove duplicates by using temp variable 7:20 - Remove duplicates by using empty Object 10:19 - Remove duplicates using SET 13:00 - End Tags and subscription to the channel Next Steps : --------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------- Must Watch Playlists ► 1. Javascript - https://youtube.com/playlist?list=PLO2l2fYgN805CokP5kaOWOhqP3-2vyXdS ► 2. Puppetter - https://youtube.com/playlist?list=PLO2l2fYgN805E5fbSnvtFM3K9c92ePS8e ► 3. Cypress - https://youtube.com/playlist?list=PLO2l2fYgN807KRpLfvvrqa1MSX8XdYxkV ► 4. Tech works - https://www.youtube.com/watch?v=ZNAdt4Oe5Sw&list=PLO2l2fYgN807CQ5H3ER__7x7LeEA10T2Z ► 5. Vbscript Basics To Advanced - https://www.youtube.com/watch?v=z_ctZDolyG0&list=PLO2l2fYgN805CuD-90ESrxRqX__-YJMym ► 6. Jmeter - https://youtube.com/playlist?list=PLO2l2fYgN806eNr5cr-TMTX8xGTW7Mtcn ► 7. Excel - https://youtube.com/playlist?list=PLO2l2fYgN806piZ2fD0bYNi3ExoPJlcqj ► 8. Appium - https://www.youtube.com/playlist?list=PLO2l2fYgN806V_9-wL-dpmrGg8dhPPONK ► 9. Shares - https://youtube.com/playlist?list=PLO2l2fYgN806ySmKp3sskJW0ByJalmPE2 ► 10. Javascript Interview Questions -https://youtube.com/playlist?list=PLO2l2fYgN807uZl7Mp7ESavluzVU25ux9 ► 11. C# Tutorials - https://www.youtube.com/playlist?list=PLO2l2fYgN805Dct9KbYNYC8nGOzwKjklt ► 12. HTML & CSS - https://www.youtube.com/playlist?list=PLO2l2fYgN804tkFuKw9DlcVXT0m8hDzdw --------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------- #javascript #removeDuplicatesInArray #javascriptInterviewQuestions

Иконка канала Кодерские идеи
63 подписчика
12+
16 просмотров
2 года назад
12+
16 просмотров
2 года назад

How to remove duplicates from an Array using different ways in JavaScript My second Channel: WrestleTalkByAzhar - https://www.youtube.com/c/wrestleTalkByAzhar Now you can Donate us via Paypal or Google Pay Paypal link : https://www.paypal.me/Azhar67 GooglePay/PhonePe/BHIM App UPI ID : shaikazharjamal@okhdfcbank Code: let a = [1,2,7,9,2,3,4,5,6,7,6,7,8,9] // 1 st way let b = [] let length = a.length for (let i=0;i(less than)length;i++){ if(!b.includes(a[i])){ b.push(a[i]); } } console.log(b) //2nd way let tempVar a.sort(); for(let i=0;i(less than)length;i++){ if(a[i] !== tempVar){ b.push(a[i]) tempVar = a[i] } } console.log(b) // 3rd way - empty object let x={} for(let i of a){ x[i] = 20 } console.log(x) console.log(Object.keys(x)) //4th way using SET let simpleSet = new Set(a) console.log(simpleSet) console.log(simpleSet.keys()) console.log([...simpleSet]) Description Tags: 5 ways to remove duplicate elements from array in JavaScript | Interview Guide Remove duplicates from array in Javascript | Algorithm Interview Question JavaScript Problem: Removing Duplicate Objects from an Array Chapters 4 easy ways to remove duplicate elements from Array - JavaScript JavaScript Interview #11: Program to Remove Duplicate Values from Array in JavaScript JavaScript How To Remove An Item From Array Tutorial Chapters: 0:00 - Introduction 0:27 - Remove duplicates First way using Includes method 4:17 - Remove duplicates by using temp variable 7:20 - Remove duplicates by using empty Object 10:19 - Remove duplicates using SET 13:00 - End Tags and subscription to the channel Next Steps : --------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------- Must Watch Playlists ► 1. Javascript - https://youtube.com/playlist?list=PLO2l2fYgN805CokP5kaOWOhqP3-2vyXdS ► 2. Puppetter - https://youtube.com/playlist?list=PLO2l2fYgN805E5fbSnvtFM3K9c92ePS8e ► 3. Cypress - https://youtube.com/playlist?list=PLO2l2fYgN807KRpLfvvrqa1MSX8XdYxkV ► 4. Tech works - https://www.youtube.com/watch?v=ZNAdt4Oe5Sw&list=PLO2l2fYgN807CQ5H3ER__7x7LeEA10T2Z ► 5. Vbscript Basics To Advanced - https://www.youtube.com/watch?v=z_ctZDolyG0&list=PLO2l2fYgN805CuD-90ESrxRqX__-YJMym ► 6. Jmeter - https://youtube.com/playlist?list=PLO2l2fYgN806eNr5cr-TMTX8xGTW7Mtcn ► 7. Excel - https://youtube.com/playlist?list=PLO2l2fYgN806piZ2fD0bYNi3ExoPJlcqj ► 8. Appium - https://www.youtube.com/playlist?list=PLO2l2fYgN806V_9-wL-dpmrGg8dhPPONK ► 9. Shares - https://youtube.com/playlist?list=PLO2l2fYgN806ySmKp3sskJW0ByJalmPE2 ► 10. Javascript Interview Questions -https://youtube.com/playlist?list=PLO2l2fYgN807uZl7Mp7ESavluzVU25ux9 ► 11. C# Tutorials - https://www.youtube.com/playlist?list=PLO2l2fYgN805Dct9KbYNYC8nGOzwKjklt ► 12. HTML & CSS - https://www.youtube.com/playlist?list=PLO2l2fYgN804tkFuKw9DlcVXT0m8hDzdw --------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------- #javascript #removeDuplicatesInArray #javascriptInterviewQuestions

, чтобы оставлять комментарии