DEV Community

Discussion on: Relearning the Past: Vanilla JavaScript Single Page Application

Collapse
 
lexlohr profile image
Alex Lohr

That's still not necessary, as you can check if your page is in pages and otherwise return home (or a 404 page):

const getPageContent = (page) =>
  pages.hasOwnProperty(page)
  ? pages[page]
  : pages.home;
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
peerreynders profile image
peerreynders

FYI:
"Note: Object.hasOwn() is recommended over hasOwnProperty(), in browsers where it is supported."