Simple script playground for executing JS scripts and demonstrating different JS array related operations.
Create an array of the past seven days, inclusive:
There are 86400000 milliseconds in each day. The expression
[0, 1, 2, 3, 4, 5, 6].
Generate a random alphanumerical
This snippet will generate a semi-random alphanumeric ids.
Why? The random float will be converted into base 36, which will be represented with 10 digits and 26 alphanumeric characters. The
.substring(2)will remove the leading 0.
Return a shuffled copy of an Array-like.
If you ever needed to mix things you, this method will move things around in an array. Because
sortwill modify an array in-place, we can take advantage of the shallow copy returned by
Generate random color.
Here, we generate a number between 0–16million, represented as a hexadecimal number. The final part,
padEnd, will ensure smaller numbers are always 6 digits long.
This only works with primitives but it’s still nifty. Set takes any iterable object, like an array
[1,2,3,3], and removes duplicates. The spread operator makes that set
If you ever needed a 3D ascii keyboard, here you go.