~ is the bitwise negation operator in js, ~ ~ is the bitwise negation twice, which actually keeps the original value, but note that although it is the original value, this operation on Boolean variables will be converted into corresponding numerical variables, that is, ~ ~ true = =1,~ ~~false === 0.
This feature is used in your example. Keystr method requires the return value to be a number, but it must be [key].