Blog Post
luk
We see .now?long used a lot in production code, and I would recommend it over anything involving strings. I believe the docs are correct that it returns the same thing as Java's Date.getTime(), so it will already be milliseconds. Otherwise, dividing by 1000 should be better than truncating characters, converting types, etc.
Re: splice, The first two cases are behaving as expected. This is from a JS console:
let seq = [1,2,3,4,5,6]; seq.splice(5, 0, 7, 8); seq;
[1, 2, 3, 4, 5, 7, 8, 6]
seq = [1,2,3,4,5,6]; seq.splice(5, 1); seq;
[1, 2, 3, 4, 5]
For the other two, I would say behavior is undefined for those cases. The example code is not an exact match of JS's splice function (like the function it replaced) — it expects 0 <= start index < (sequence length - delete count), which I would consider the "normal case". If you choose to use the example function code and you expect out-of-bounds input like those, you could add either an extra validation step to reject the input or extra logic to handle those cases.