Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. // Suppose jqArr is the array stated above:
  2. var result = [];
  3.  
  4. angular.forEach(jqArr, function(v_i){
  5. if(result.length === 0){
  6. result.push(v_i);
  7. } else {
  8. var isPushed = false;
  9. angular.forEach(result, function(v_j){
  10. if(angualr.equals(v_i, v_j)){
  11. isPushed = true;
  12. }
  13. });
  14. if(isPushed === false){
  15. result.push(v_i);
  16. }
  17. }
  18. })
  19. console.log(result);
  20.  
  21. [e_1, e_2, e_3]
  22.  
  23. let arr = [1,1,2,2,2,3,4,5,6,6,6,6,6];
  24. let uniq = [...new Set(arr)];
  25.  
  26. var result = [],
  27. jqArr = [e_1, e_2, e_3, e_1, e_2];
  28.  
  29. angular.forEach(jqArr, function(v_i){
  30.  
  31. // push only the object that aren't inside the result array
  32. if(result.indexOf(v_i)===-1)
  33. result.push(v_i);
  34. })
  35. [e_1, e_2, e_3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement