Javascript Uncaught SyntaxError: Unexpected identifier

old school (internet explorer), you need to change as the previous answers stated

var person={
    first_name:"John",
    last_name:"doe",
    id:5577,
    //     ^ missing comma
    fullName: function(){
    //      ^ missing colon
        return this.first_name+" "+this.last_name;
    }
}

ES2015 (ES6) has a shorthand

var person={
    first_name:"John",
    last_name:"doe",
    id:5577,
    //     ^ missing comma
    fullName(){
    //      ^ no need for "function" keyword
        return this.first_name+" "+this.last_name;
    }
}

Leave a Comment