The problem is that you are trying to use new for an object, but it can actually target functions. Try instead
var IOBreadcrumb = function IOBreadcrumb() { this.breadcrumbs = []; this.add = function(title, url) { var crumb = { title: title, url:url }; this.breadcrumbs.push(crumb); }; };
Alternatively, you can also use the prototype here and share the definition of add among several instancces
var IOBreadcrumb = function IOBreadcrumb() { this.breadcrumbs = []; }; IOBreadcrumb.prototype.add = function (title, url) { var crumb = { title: title, url:url }; this.breadcrumbs.push(crumb); };
source share