Guest User

Untitled

a guest
May 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. Array.prototype.unique = function() {
  2. var uniqueKeys = {};
  3. var items = this.length;
  4. while ( items ) {
  5. uniqueKeys[ this[ --items ] ] = true;
  6. }
  7.  
  8. var uniqueArray = [];
  9. for ( var key in uniqueKeys ) {
  10. if ( uniqueKeys.hasOwnProperty( key ) ) {
  11. continue;
  12. }
  13. uniqueArray.push( key );
  14. }
  15.  
  16. return uniqueArray;
  17. }
Add Comment
Please, Sign In to add comment