[Vuejs]-Can I use the logical OR operator with Strings in function arguments in JS? Function does not evaluate the second string (I think)

1👍

It stops at the first argument because that’s the first argument that is truthy, so the other arguments are ignored. If you attempted to call the function with undefined first (falsy value), it would skip that one and send the second argument.

One way to accomplish your intended goal would be to send all possible arguments as an array of arguments and use Array.includes() in your function:

getNumber() {
  return this.getErrorByMemberId(['Cvr', 'B2Bvr', undefined]);
},
const getByTitle = (memberTitleArray) => {
  return state.errors.find(e => memberTitleArray.includes(e.meta.memberTitle))
       ?.content.error.title;   
}
👤yoduh

Leave a comment