Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = [5,6,3,3,1,2,4]
- // Remove Duplicates
- A = new Set(A)
- A = [...A]
- // Ascending Order 1 first
- A = A.sort(function(a, b){return a-b});
- // Descending Order 1 last
- A = A.sort(function(a, b){return b-a});
- // Turn Integer to Binary
- N = (N).toString(2);
- // Break string into array
- N = N.split("")
- // One line if statement
- (a>b) ? doThis : doThis
- if (lemons) document.write("foo gave me a bar");
- // Fastest for loop
- for (var i = 0, len = myArray.length; i < len; i++) {
- }
- // Sort objects by value
- const order = state => ({
- desc: (opt) => {
- return state.sort((a, b) => (a[opt] < b[opt]) ? 1 : -1)
- },
- asc: (opt) => {
- return state.sort((a, b) => (a[opt] > b[opt]) ? 1 : -1)
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement