I have an object, called user, which may or may not have subproperties defined. For example, sometimes there is no "pages" object, sometimes you can go user.pages.someothervariable.
I can see in EJS how to check that user exists, but how can I check that user.pages.someothervariable exists without getting a "cannot access property of undefined" error.
I've tried this and typeof, but cannot get it to work.
<% if(locals.user.pages.pageVisits){ %>foo defined<% }else{ %>foo undefined<% } %>
I get this error:
Cannot read property 'pageVisits' of undefined