JavaScript Syntaxt conditional syntaxt ? and


Often finding conditional syntax like array followed by "?" and "." and element, example – edges[0]?.node . How to interpret the code?

export default function Index({ allPosts: { edges }, preview }) {
  const heroPost = edges[0]?.node;
  const morePosts = edges.slice(1);
  ....// rest of the code 
}

 

Source: JavaSript – Stack Overflow

October 29, 2021
Category : News
Tags: conditional-statements | javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.