Short intro about string functions in JavaScript

Learn about available JavaScript string functions. Image taken from unsplash String Properties 1.length var str = “Jagathish”;str.length; //9 –> returns the length of the string Functions toUpperCase() –> returns the new string in uppercase format of source string var str = “Jagathish”; var str2 = str.toUpperCase(); console.log(str);//Jagathish console.log(str2);//JAGATHISH 2.toLowerCase() –> returns the new string in lowercase …

String methods : startsWith in Javascript.

Learn about the startsWith method of string object in Javascript. The startsWith() method returns true if the given characters are found at the beginning of the string, otherwise, false. If you want this method to be non case-sensitive then we can write a custom function We can also specify the position from which to begin …

Removing space in string in Javascript

Learn how to remove space in string. If you want to remove all the space in the string then , you can use replace method var name = “Javascript jeep “; name.replace(/s/g,”); // Javascriptjeep s –> spaceg –> replace globally We can also replace the space with ‘-‘ var name = “Javascript jeep “; name.replace(/s/g,’-‘); // …

Difference between String primitives and String object.

Learn about, in what way the string primitive and string objects are different in javascript. We can create string in three ways, 1. var a = “first way”; // we can also use single quotes 2. var b = String(“second way”); 3. var c = new String(“third way”); // also we can create using 4. …

Design a site like this with WordPress.com
Get started