Let suppose we he a code block below -
function football(){
let options = {}
let [r, s, e] = ['Ronaldo', 'Messi', 'Aguero']
if(true){
options = {league: 'Premier League'}
[r, s, e] = ['Grealish', 'De Bruyne', 'Ramos']
console.log(options, r, s, e)
}
}
football()
Output of this code is - ['Grealish', 'De Bruyne', 'Ramos'] Ronaldo Messi Aguero
Please suggest the reason why object assignment didn't work here without ; semicolon
in the options
variable.
If we put a semicolon ;
after like this- options = {league: 'Premier League'};
then this would give the expected output - {league: 'Premier League'} Grealish De Bruyne Ramos
.
Please anyone can explain the reason?
Thanks in advance