Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jyotiarora2610/9f9bdd9d8c3adfee6eeedf5a40b442db to your computer and use it in GitHub Desktop.
Save jyotiarora2610/9f9bdd9d8c3adfee6eeedf5a40b442db to your computer and use it in GitHub Desktop.
var arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 7, 8, 7, 1, 2, 3]
var finalArr = []
arr.forEach(function (element, index) {
if(arr.indexOf(element, index + 1) > -1) {
finalArr.push(element)
}
})
console.log(finalArr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment