typeof operator returns a string as a result giving the type of an operand.
#Line number 5:
Math.LN4 mean natural log of 4 whose output is
Math.LN4 =ln(4) which is nearly equal to 1.3863
#Line number 7 :
This is one of the odd nature of typeof which output ‘number‘ string though it’s a Not a Number. This idiosyncrasy will be picked in many interviews and need to be in mind for proper coding practice.
#Line number 8 and 9 :
Number() function tries to parse the string to a number so line number 8 gives ‘number’ as output. In addition, line number 9 also gives a number.
This is because Number() tries to coerce the string inside which is ‘shoe’. Number(‘shoe’) return NaN and from line number 7, we know that typeof NaN is ‘number’.
#in line number 4, we can see ‘1’ is also a string because a number within a string is string type.
#In line number 5, typeof 1 operator always return string ie ‘number’ . So typeof ‘number’ is ‘string’
#In line number 6, String(1) function convert integer 1 into a string.
#Line n. 3: – This new Date( ) is a constructor that creates a new date object with the current date and time.
#Line n. 5-8: In JS, new operators create a new object which is inherited from the contractor’s prototype so typeof returns ‘object’.
typeof is asked in an interview most of the time. It is required for a programmer to know about this operator so this is a bank of the typeof operator that I wanted to create that you can come and check back when needed.
Thank you for reading and your time.
Happy Learning, Happy Coding.
Stay Safe and Take Care. Help others in need.
See you soon !!!1