Elementals.js

Latest Version: 2.0 RC 3 14 March 2017

Method _.stringNormalize

Summary:

Turns the passed variable into an empty string if the type is undefined, otherwise typecasts to string and trims off leading/trailing whitespace.

This is useful for cases where you are unsure of the variable's content. Used internally several times in the elementals.js codebase.

Calling Convention:
_.stringNormalize(variable)
Parameters:
variable
The variable to typecast to string and trim.
Returns:
The "normalized" string.

Example

JavaScript

Console.log(_.stringNormalize(' this is a test '));

Will output the string with the whitespace removed from it.