oop - Unexpected identifier in Javascript Object -
i creating following object:
var iobreadcrumb = { breadcrumbs: [] add: function(title, url){ var crumb = {title, url}; this.breadcrumbs.push(crumb); } };
i getting unexpected identifier error. not sure coming from, in block of code.
you need comma between members of object, cause of error cite. need put colon, rather comma, between key-value pair in crumb
object.
var iobreadcrumb = { breadcrumbs: [], // <-- comma here add: function(title, url){ var crumb = {title: url}; // <-- colon here this.breadcrumbs.push(crumb); } };
if want object there 2 members, 1 title , 1 url, may want this:
var crumb = { title: title, url: url };
i don't know whether work breadcrumbs
setup...
Comments
Post a Comment