EDIT: according Stéphane Chazelas sh language.
When you use ./scriptname.sh it executes with /bin/bash as in the first line with #! but not with. But when you use sh scriptname.sh it executes sh, not bash.
The Shell havesh shell has no syntax to create arrays, but Bash havehas the syntax you used.