Uderstanding string assignment and quotes for numbers

Hello!

I’ve read this many times, but still don’t understand why we would assign a string to a number…especially if it is written in numerical.

I can understand it - if numbers are included in a sentence, but, in what context does a string gets assigned to a single numerical number?

Also, can double quotes and single quotes be used interchangeably at will (for a numerical “string” / ‘string’ value?

1 !=  2    // true
1 != "1"   // false
1 != '1'   // false
1 != true  // false
0 != false // false

Thanks for your time if you read this message,
Phil.

!= is a comparison operator, not an assignment

it is checking if the first element is loosely equal to the second

all strings can be written with single or double quotes

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.