Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

brandonlind2
brandonlind2
7,823 Points

What is the use of a Boolean and String object?

I'm reading the MDN and I stumbled across these objects and I'm confused as to what theyre used for, for example what would I use the code below for?

var booleanObj= new Boolean('t');

its not a boolean value, so im not understanding the use, why does the Boolean object exists in javascript?

1 Answer

In case you need to run functions on an Object instead of a primitive boolean value... I can't think of a good example why you would want to, but it's there if you need it! :)

brandonlind2
brandonlind2
7,823 Points

so for example if I wanted to call a function that is in the Object object on a boolean value, I could change it to a object with the Boolean value, then call the function then change it back to a boolean value?