Error Invalid Shorthand Property Initializer In Javascript
Why I got error Invalid shorthand property initializer when running on my Chrome browser?
Solution 1:
You do not use '=' inside object literals. It should be raichu : {
letsamson_pokemon= {
raichu : {
species:'Rare pokemon',
height:0.8,
weight:12
}
}
Solution 2:
you can do this.
let weight4 = (typeof samson_pokemon !== 'undefined') ? samson_pokemon.pikachu : samson_pokemon.weight;
Post a Comment for "Error Invalid Shorthand Property Initializer In Javascript"