-4

how can I apply the ?? operator in JS (can I do it anyway ?) I just want to assing the default value to someVariable if defaultDirection is undefined or get the defaultDirection value if it's not

function myFunc(defaultDirection) {
    var someVariable = defaultDirection ?? false;
}
Tony
  • 12,405
  • 36
  • 126
  • 226

1 Answers1

1

You would use pipes to do this:

function myFunc(defaultDirection) {
    var someVariable = defaultDirection || false;

}
donnywals
  • 7,241
  • 1
  • 19
  • 27