<script type="text/javascript">
var str = "red and white";
var length = str.length;
document.write("String Length :- "+length);
</script>
Output :-
String Length :- 13
String convert lower to uppercase
<script type="text/javascript">
var str = "red and white";
var value = str.toUpperCase();
document.write("String Length :- "+value);
</script>
Output :-
String Lower to Uppercase :- RED AND WHITE
String convert Upper to lowercase
<script type="text/javascript">
var str = "red and white";
var value = str.toLowerCase();
document.write("String Length :- "+value);
</script>
Output :-
String Upper to Lowerrcase :- red and white
Two String Join
<script type="text/javascript">
var str1 = "hello";
var str2 = "javascript";
var value = str1.concat(" "+str2);
document.write("Joint String :- "+value);
</script>
Output :-
Joint String :- hello javascript
Remove whitesapce to string
<script type="text/javascript">
var str = " hello red and white ";
var value = str.trim(str);
document.write("Remove whitespace :- "+value);
</script>
Output :-
Remove whitespace :- hello red and white
String Slice
<script type="text/javascript">
var str = "mobile, laptop, t.v, freez, washing machine";
var value = str.slice(8,14);
document.write("Slice string :- "+value);
</script>
Output :-
Slice string :- laptop
<script type="text/javascript">
var str = "mobile, laptop, t.v, freez, washing machine";
var value = str.slice(16);
document.write("Slice string :- "+value);
</script>
Output :-
Slice string :- t.v, freez, washing machine
String Replace
<script type="text/javascript">
var str = "Red and White";
var value = str.replace("Red","orange");
document.write("String replace :- "+value);
</script>
Output :-
String replace :- orange and White
<script type="text/javascript">
var str = "Orange and White Orange white is best institute";
var value = str.replace(/Orange/g,"Red");
document.write("String replace :- "+value);
</script>
Output:-
String replace :- Red and White Red white is best institute
charAt() method
<script type="text/javascript">
var str = "Red and White";
var value = str.charAt(2);
document.write("Ans :- "+value);
</script>
Output :-
Ans :- d
charCodeAt method
<script type="text/javascript">
var str = "Red and White";
var value = str.charCodeAt(2);
document.write("Ans :- "+value);
</script>
Output :-
Ans :- 100
<script type="text/javascript">
var str = "Red and White";
var value = str.indexOf('d');
document.write("Ans :- "+value);
</script>
Output :-
Ans :- 2
Search() method
script type="text/javascript">
var str = "Red and White";
var value = str.search('and');
document.write("Ans :- "+value);
</script>
Output :-
Ans :- 4
substring() method
<script type="text/javascript">
var str = "Red and White";
var value = str.substring(8,13);
document.write("Ans :- "+value);
</script>
Output :-
Ans :- White
split() method
<script type="text/javascript">
var str = "Red and White";
var value = str.split(" ");
console.log(value);
</script>
Output :-
Ans :- ['Red', 'and', 'White']