Search code examples
google-closuregoogle-closure-library

Google Closure Library: What's the "correct" way to parse a boolean?


One of the things I have learned in dealing with Google Closure is that the library has virtually everything I could possibly want in terms of raw data manipulation and management. What's up to me is to build the components on top of it.

Today I was trying to parse a boolean value from a string. I was surprised not to find anything in the Google Closure Library to do this.

Am I supposed to build this myself via the techniques referenced in the question " How can I convert a string to boolean in JavaScript?", or is there another "Google Closure way"™ to parse booleans that I failed to find?


Solution

  • Nope, there is no Closure way to do that.

    You either follow the advice mentioned in the question you link to, or create your own method that incorporates what string you consider to be true and what false.