{"id":1673,"date":"2022-07-11T20:11:42","date_gmt":"2022-07-11T20:11:42","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=1673"},"modified":"2022-07-11T20:11:45","modified_gmt":"2022-07-11T20:11:45","slug":"javascript-string-methods","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/javascript-string-methods\/","title":{"rendered":"JavaScript String Methods"},"content":{"rendered":"<p style=\"text-align: center;\"><strong>JavaScript String Methods<\/strong><\/p>\n<p>With the help of string methods, we can simply do many different things with the strings(this is basically doing some operations on the strings, like calculating the length of the string, converting the string to lowercase or uppercase, and so on&#8230;). Let&#8217;s have a look at some different methods related to the strings here &#8211;<\/p>\n<h4>Calculating the length of a string (length property)<\/h4>\n<p>The first thing that we are talking about here, is not actually a method, but a property, using which, we are calculating the length of the string.<\/p>\n<p>So, if you want to get the length of a string, it&#8217;s super easy. You just need to use the length property. Following is an example that demonstrates the use of the length property to calculate the length of a string. The length of a string is nothing but the number of characters in the string. A string with no characters has a length of zero, and a character is just a single-length string &#8211;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1674 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Calculating-the-length-of-a-string-length-property.jpg\" alt=\"\" width=\"801\" height=\"207\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Calculating-the-length-of-a-string-length-property.jpg 801w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Calculating-the-length-of-a-string-length-property-300x78.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Calculating-the-length-of-a-string-length-property-768x198.jpg 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/p>\n<p>As you can see, we have used the property length here, and notice how are we using it, like the variable name, followed by the dot, and then the length property. Have a look at the output now \u2192<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1675 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Calculating-the-length-of-a-string-length-property-1.jpg\" alt=\"\" width=\"911\" height=\"190\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Calculating-the-length-of-a-string-length-property-1.jpg 911w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Calculating-the-length-of-a-string-length-property-1-300x63.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/06\/Calculating-the-length-of-a-string-length-property-1-768x160.jpg 768w\" sizes=\"auto, (max-width: 911px) 100vw, 911px\" \/><\/p>\n<p>As you can see, we could get the length of the different strings that we have made in the program. If you ever need the length of some string, we can make use of the length property, and easily get the length of the string.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript String Methods With the help of string methods, we can simply do many different things with the strings(this is basically doing some operations on the strings, like calculating the length of the string, converting the string to lowercase or uppercase, and so on&#8230;). Let&#8217;s have a look at some different methods related to the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14,15],"class_list":{"0":"post-1673","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-javascript-tutorial","7":"tag-javascript","8":"tag-javascript-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=1673"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1673\/revisions"}],"predecessor-version":[{"id":2218,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/1673\/revisions\/2218"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=1673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=1673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=1673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}