Subscribe on changes!

Unexpected behaviors for adding integer prop out of valid array length on array

avatar
May 23rd 2021

Version

3.0.11

Reproduction link

https://codesandbox.io/s/quizzical-wind-okivm?file=/src/main.js

Steps to reproduce

open console

What is expected?

  • effect should run 1 times

What is actually happening?

  • effect run 2 times

The valid array length is from 0 to Math.pow(2, 32) - 1, AKA 4294967295. If a array integer prop is out of valid array length, it will be treated as a object key not a array index.

  • adding integer prop less than or equal valid array length to array will change the length of array

  • adding integer prop out of valid array length to array doesn't change the length of array

  • array.length will never be bigger than 4294967295