What is a better way to assign variables to values of an object [closed]

  javascript, reactjs

What is a better way to write this in JS

let foo
  if(bar) foo = bar.value

I am trying to avoid react error when bar is null if i use const foo = bar.value.

Source: Ask Javascript Questions

LEAVE A COMMENT