What JavaScript value should you assign to a variable x so that typeof x = = = x would be true?

225 views Asked by At

I've tried assigning different data types such as boolean, numbers, strings, objects, nulls, etc, but keep getting false returned. Any ideas?

1

There are 1 answers

0
Phrogz On

The typeof operator always returns a string value. As such, your original value must be a string. The result of typeof for a string is "string", and so:

x = "string"
typeof x === x // true