correct way of comparing string jquery operator =

No. = sets somevar to have that value. use === to compare value and type which returns a boolean that you need.

Never use or suggest == instead of ===. its a recipe for disaster. e.g 0 == “” is true but “” == ‘0’ is false and many more.

More information also in this great answer

Leave a Comment