{"id":566,"date":"2020-08-23T19:36:31","date_gmt":"2020-08-23T19:36:31","guid":{"rendered":"https:\/\/datatype.co.in\/blog\/?p=566"},"modified":"2020-08-26T09:48:17","modified_gmt":"2020-08-26T09:48:17","slug":"trim-all-whitespaces-from-string-in-javascript","status":"publish","type":"post","link":"https:\/\/datatype.co.in\/blog\/trim-all-whitespaces-from-string-in-javascript\/","title":{"rendered":"Trim All Whitespaces From String in JavaScript"},"content":{"rendered":"\n<p>JavaScript&#8217;s inbuilt method <strong><code>trim()<\/code><\/strong> removes whitespace from both ends of a string. <\/p>\n\n\n\n<p><strong>The Syntax:<\/strong> <strong><code>str.trim()<\/code><\/strong><\/p>\n\n\n\n<p>The method returns new string representing the&nbsp;<code><strong>str<\/strong><\/code>&nbsp;stripped of whitespace from both ends. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var message = \" Hello World  \";\nconsole.log(message.trim());\n\/\/ Output: \"Hello World\"<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/datatype.co.in\/code-editor\">Try yourself<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript&#8217;s inbuilt method trim() removes whitespace from both ends of a string. The Syntax: str.trim() The method returns new string representing the&nbsp;str&nbsp;stripped of whitespace from both ends. Try yourself<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[176,100,191,194,192],"class_list":["post-566","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript","tag-js-interview-question","tag-js-trim-whitespace","tag-string","tag-trim","list-style-post"],"_links":{"self":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/comments?post=566"}],"version-history":[{"count":8,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/566\/revisions"}],"predecessor-version":[{"id":574,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/posts\/566\/revisions\/574"}],"wp:attachment":[{"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/media?parent=566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/categories?post=566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datatype.co.in\/blog\/wp-json\/wp\/v2\/tags?post=566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}