Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. A = [5,6,3,3,1,2,4]
  2.  
  3. // Remove Duplicates
  4. A = new Set(A)
  5. A = [...A]
  6.  
  7. // Ascending Order 1 first
  8. A = A.sort(function(a, b){return a-b});
  9.  
  10. // Descending Order 1 last
  11. A = A.sort(function(a, b){return b-a});
  12.  
  13. // Turn Integer to Binary
  14. N = (N).toString(2);
  15.  
  16. // Break string into array
  17. N = N.split("")
  18.  
  19. // One line if statement
  20.  
  21. (a>b) ? doThis : doThis
  22. if (lemons) document.write("foo gave me a bar");
  23.  
  24. // Fastest for loop
  25. for (var i = 0, len = myArray.length; i < len; i++) {
  26.  
  27. }
  28.  
  29. // Sort objects by value
  30. const order = state => ({
  31. desc: (opt) => {
  32. return state.sort((a, b) => (a[opt] < b[opt]) ? 1 : -1)
  33. },
  34. asc: (opt) => {
  35. return state.sort((a, b) => (a[opt] > b[opt]) ? 1 : -1)
  36. }
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement