We can't do multiple "!=="?

Hi vue.js community!!!
I just made a very strange discovery in vue.js!
Do you know why it is possible to create several equalities with “||”. But that it is obviously not possible to do the same thing with an inequality?

See for example, in the following example: Vue SFC Playground

The first condition works fine with “===”
But the second with “!==” doesn’t work at all!

It’s very weird I think…

Do you know if there is an explanation?

Good to know, I just blocked on it for 40 minutes. :rofl: :joy: :rofl:

Thank you :slight_smile:

This is just javascript.

Your first condition matches jesse and so it displays.

Your second condition doesn’t match jesse and therefore will always equate to true so it also displays.

const myVar = 'jesse'
const val = myVar !== 'walter' || myVar !== 'white'

console.log(val) // Will always equate to true

Fiddle: https://jsfiddle.net/jamesbrndwgn/ux76tew4/

Hi @sbillois

|| operator displays true if any one of the condition is true, So you can use && operator as it gives the answer true only if all the conditions are true.

And for better way you can also create computed property for this

<div v-if="condition">
    <p>Yo !!! 2</p>
  </div>

computed: {
    condition() {
      this.myVar;
      return this.myVar !== 'walter' && this.myVar !== 'white';
    },
  },

Hope this helps!!