<script> var str =" hello "; var arr = []; arr.push(str.trim()); console.log(arr); //["hello"] </script>