Consider the following code snippet.
Code snippet as a picture
What’s going to be printed to the console? (think well, then click for the answer and explanation)
The first line, defines the variable
strand initializes it as a string with the value
The second line of code does two typecasts, first the exclamation mark converts the string into boolean and negates it with
!str. This gives you
Then the plus sign converts boolean into a number with
0. The number 0 is saved into the variable
Eventually, in the third line, the
typeofoperator looks up the current type of
numberwill be printed to the console.