I have the following object in a JS file:
var IOBreadcrumb = function IOBreadcrumb() {
this.breadcrumbs = [];
this.add = function(title, url) {
var crumb = {
title: title,
url:url
};
this.breadcrumbs.push(crumb);
};
};
In another JS file I want to utilize this object:
//this occurs in some on click event
var breadcrumb = new IOBreadcrumb();
breadcrumb.add('some title',url);
console.log(breadcrumb.breadcrumbs);
I would like there to only be 1 instance of IOBreadcrumb, so that when I click on a button, it will always add a breadcrumb to the array.
How can I accomplish this?
Then: