boolean

Syntax boolean (value)

Params value is the object whose datatype you wish to convert to boolean.

Action Converts value to be a boolean datatype value if possible.

Returns boolean value of true or false if coercion is successful.

Examples boolean (0)

   » false // 0 is always false

boolean (1)

   » true // 1 is always true

boolean (235)

   » true // Any non-zero value is always true

boolean ("Hello")

   » true // Any non-empty string is true

boolean ("")

   » false // An empty string is false

Discuss