0

Array

[ li.size30x30, li.size60x30, li.size60x30, li.size30x30, li.size60x30,
  li.size60x30, li.size60x30, li.size60x30, li.size30x30, 704 more… ]

expect result Array [ li.size30x30, li.size60x30 ]

1

1 Answer 1

1

You can use filter() and indexOf() here

var arrayEl = ['li.size30x30', 'li.size60x30', 'li.size60x30', 'li.size30x30', 'li.size60x30',
  'li.size60x30', 'li.size60x30', 'li.size60x30', 'li.size30x30'
];

arrayEl = arrayEl.filter(function(v, i, arr) {
  return i == arr.indexOf(v);
  // checking array element already occured before the element using indexOf(), which returns index of first occurance 
});

document.write(JSON.stringify(arrayEl));

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.