Typeof


#1

Hey i’m doing this course alongside reading beginning javascript book and various online videos.

Today I decided to go through the object part of javascript as I’ve just gone through a lot of and wanted some practice situations to help it stick in my brain. when I got to question 12 and 13. i noticed within the examples of adding a setter there was the word typeof in the if statement now this may be due to me getting a little frustrated and missing it but I don’t see a clear explanation of why it is there in these setters if statements or what the term is used for in any useful amount of detail the one thing I did notice is the if statement doesn’t work at all without it but will not cause an error to work from.
I don’t know why its there I don’t know when it should be there I don’t know what its actually doing is this exclusive to setters or does it have a deeper purpose I’ve managed to skip over

could someone explain the uses of typeof or give me a resource which explains this fairly well?

many thanks
daisy
x


#2

MDN always has good documentation, google:

typeof mdn

but the name of the statement is pretty self explaining, it gives you the data type of variable.


#3

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