)
}
}
)
(
}
{
)
)
(
)
(
(
{
}
)
(
)
}
)
)
{
(
(
)
)
}
)
(
}

toString Hack Obfuscated

  1. x=''+self 
  2. j=''
  3. 'd1d7a1712345691a7512d427b1da7d9ab7519a4b721a961721d694'
  4. .split``
  5. .map(_=>j+=`x[0x${_}]+`)
  6. console.log(eval(j+'""'))

Yesterday’s snippet saying something else…

It’s simpler than it looks:

  1. x=''+self 
  2. // becomes "[object Window]"
  3.  
  4. j='' 
  5. // initialize `j` which will be javascript to pass to `eval`
  6.  
  7. 'd1d7a17123456...' 
  8. // this is a list of index values to 
  9. // look up in `x` in hexidecimal so that each 
  10. // index is a single character
  11.  
  12. .split``
  13. // split the index values into an array `[0xe, 0x2 ...`
  14.  
  15. .map(_=>j+=`x[0x${_}]+`)
  16. // map over the index values and write a string like
  17. // this `x[0xe]+x[0x2]+...` into `j`
  18.  
  19. console.log(eval(j+'""'))
  20. // evaluate `j` with an empty string at the end
  21. // `x[0xe]+x[0x2]+""` and log it out
`

Combine Two or More Arrays

  1. const numbers = [1, 2, 3];
  2. const letters = ['a', 'b', 'c'];
  3. const symbols = ['!', '@', '#'];
  4.  
  5. // use spread operator
  6. const combined = [...numbers, ...letters, ...symbols];
  7. console.log('first', combined);
  8.  
  9. // older way
  10. const combinedConcat = numbers
  11.   .concat(letters)
  12.   .concat(symbols);
  13.  
  14. console.log('second', combinedConcat);

If you click “Try it out” be sure to open your console.

Shuffle an Array

  1. const nums = [1, 10, 20, 30, 50, 88];
  2. nums.sort(() => Math.random() - 0.5);
  3. console.log(nums);

Common way to shuffle the values in an array.

snippet.zone ~ 2021-24 /// {s/z}