Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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?