Based on a quick mockup like below I need to add URL route objects to an Array property in my app.
in the function below addAppRoute(routeObbj) I would like to add a check to see if the new route being added already exist or not in the property this.cache.webDevAppRoutes
How can I make sure duplicates are not added? It would need to be based on a duplicate module and action being the same
var app = {
cache: {
webDevAppRoutes: [],
},
addAppRoute: function(route) {
var routes = this.cache.webDevAppRoutes;
routes.push(route);
},
getAppRoutes: function() {
var routes = this.cache.webDevAppRoutes;
console.log(routes);
},
addBookmarkAppRoutes: function() {
this.addAppRoute({
module: 'bookmarks',
action: 'view',
params: [{
id: 123
}],
});
this.addAppRoute({
module: 'bookmarks',
action: 'edit',
params: [{
id: 123
}],
});
this.addAppRoute({
module: 'bookmarks',
action: 'add',
params: [],
});
},
}