-2

Console logging this.byPassViewState returns ["01"]

if i do this.byPassViewState === ['01'] it returns false

typeof(this.byPassViewState) retuns object

My question is why this.byPassViewState returns false ? it suppose to be true right ? please tell me what i'm doing wrong here

enter image description here

Arun K
  • 73
  • 6

1 Answers1

0

You cannot compare 2 array with just using == or === operators.
The easiest way to compare array is using JSON.stringify().

let byPassViewState = ["01"];
let compare = (JSON.stringify(byPassViewState) == JSON.stringify(["01"]) );
console.log(compare);

Please Reference : How to compare arrays in JavaScript?

Sam Ho
  • 206
  • 1
  • 4