[ERROR] SyntaxError:Invalid shorthand property initializer


#1


https://www.codecademy.com/courses/javascript-beginner-en-9Sgpi/3/2?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: Invalid shorthand property initializer


var obj  = { name : "Rohit" , age = 21 };
var obj2 = { name : "Rahul" , age = 25 };
var newArray = [ [obj,obj2],[obj1] ];


#2

@copsehindme,
The actual error-message would be

SyntaxError: ':' is expected

Look at obj and obj2


#3

Oh yes thankyou so much!


#4

In literal notation you must always use a colon : not an equal sign =. :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.