let code= "codedamn";
Parameters: This method takes only one parameter, indexOfCharacter, which is the index of any string’s character.
let code =’Codedamn’; let damn= ‘Codedamn is the best platform to " + "learn and experience development.'; // Print the string as it is document.write(code); document.write("<br>"); document.write(damn); document.write("<br>"); // As string index starts from zero // It will return first character of string document.write(code.charAt(0)); document.write("<br>"); document.write(damn.charAt(5));
The method charCodeAt(indexOfCharacter) returns an integer that indicates the Unicode value of the character at the supplied index. Only one parameter is accepted by this procedure.
concat( objectOfString ) Method: It concatenates two strings and returns combined output.
let code= 'Codedamn'; let damn= 'Hello'; // Accessing concat method on an object // of String passing another object // as a parameter document.write(code.concat(damn));
endsWith(queryString, length) Method: This function determines whether a string contains the supplied string of characters at the end. If the string ends with the specified string, this method returns
true otherwise it returns false. It’s important to note that this approach is case-sensitive. There are two arguments that can be passed to this procedure.
queryString: The string that will be looked up.
length: The length of the string you provided is the default value.
let code= 'Codedamn'; let damn= 'Hello'; document.write(damn.endsWith('lo'));
fromCharCode(UNICODE_NUMBER) Method: UNICODE values are converted to characters using this method. This is a String object’s static method. The first method does not use the string variable as a starting point. This function returns the character associated with the supplied UNICODE. This method takes only one parameter, UNICODE-NUMBER, which is the number for which you want to generate a character.
let code= ‘Codedamn'; let damn= 'Hello'; document.write(String.fromCharCode(104));
toLowerCase(stringVariable) Method: This method transforms all of the characters in a string to lowercase and provides a new string containing only lowercase characters. This function takes only one parameter: stringVariable string to change to lowercase.
let code= ‘Codedamn'; let damn= 'Hello'; document.write(code.toLowerCase(code));
toUpperCase(stringVariable) Method: This function changes all of the characters in a string to upper case and returns a new String containing only upper case characters. This function takes only one parameter: stringVariable string to change to upper case.
let code= ‘Codedamn'; let damn= 'Hello'; document.write(code.toUpperCase(code));
trim() Method: This method is used to remove either white spaces or punctuation marks from a string. This method creates a new string with the white spaces deleted. A String object was used to call this method. There are no parameters accepted by this procedure.
let code= ‘Codedamn'; let damn= 'Hello'; // Storing new object of string // with removed white spaces var newCode =code.trim(); // Old length document.write(code.length); document.write("<br>"); // New length document.write(newCode.length)
Hope you like it.
Free money-back guarantee
Unlimited access to all platform courses
100's of practice projects included
ChatGPT Based Instant AI Help (Jarvis)
Structured Full-Stack Web Developer Roadmap To Get A Job
Exclusive community for events, workshops
Sharing is caring
Did you like what mansi wrote? Thank them for their work by sharing it on social media.
No comments so far
Leave a question/feedback and someone will get back to you