What does this note mean?

Tell us what’s happening: So far, for every freeCodeCamp lesson, if I don’t understand something, which is in the text portion of the lesson, then I generally understand it when I watch the video. In this lesson, however, I understand everything in the lesson EXCEPT the note. What is the note trying to say? When I watched the video–it talked about the lesson, but didn’t explain what is meant by the note.

The note says:

Note: In JavaScript, you can determine the type of a variable or a value with the typeof operator, as follows:

typeof 3
typeof '3'

typeof 3 returns the string number , and typeof '3' returns the string string .

What are we to learn from this? Is “typeof” code? Pseudo code to explain a principle? Did I miss something about the typeof or is there more coming later in the course?

Challenge: Practice comparing different values

Link to the challenge:

Anything wrapped in quotes "" are strings even if you put a number in it shows as a string. If it is a number and is not in quotes it is a number. typeof is just an operator in JavaScript


console.log(typeof 42);
//expected output: "number"

console.log(typeof 'some text');
//expected output: "string"

console.log(typeof true);
//expected output: "boolean"

console.log(typeof null);
//expected output: "object"

Hope this helps


you can use typeof to know the type of a value, if it’s a number, a string, an object…
more about typeof:

1 Like

Thank you to both of you for your thoughtful and helpful answers. I did dig a bit deeper, after reading over both of your replies and the link.

I did find this typeof operator presented in the Debugging unit later in this course’s challenges. So I don’t think anyone coming across this challenge’s note about typeof needing to be too concerned about not fully understanding how and when to use it from this challenge alone–as the later course materials go into it more in depth.

Asking around and searching, I also found this write about it and the data types here on fcc: JavaScript TypeOf – How to Check the Type of a Variable or Object in JS

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