trimming spaces in js code example Example 1: javascript trim spaces value = value.trim(); Example 2: javascript whitespace strip yourvariable.trim()