let str =
new
String(
"A Online Computer Science Portal"
);
let str1 =
new
String(
"Computer Science Portal for Geeks"
);
console.log(
"str.charAt(0) is = "
+ str.charAt(0));
console.log(
"str.charCodeAt(0) is = "
+ str.charCodeAt(0));
console.log(
"str1.concat('=>Geeks?') = "
+ str1.concat(
'=>Geeks?'
));
console.log(
"str.indexOf('of') = "
+ str.indexOf(
'of'
));
console.log(
"str.lastIndexOf('of') = "
+ str.lastIndexOf(
'of'
));
console.log(
"str.localeCompare( 'A Online Computer Science Portal') = "
+ str.localeCompare(
'A Online Computer Science Portal'
));
console.log(
"str.localeCompare( 'Computer Science Portal for Geeks') = "
+ str.localeCompare(
'Computer Science Portal for Geeks'
));
console.log(
"str.localeCompare( 'A Computer Science Portal') = "
+ str.localeCompare(
'A Computer Science Portal'
));
if
(str.search(
"Geeksfor"
) != -1) {
console.log(
"Geeks exist in str."
);
}
else
{
console.log(
"Geeks doesn't exist in str."
);
}
console.log(
"str.slice(5, -1) = "
+ str.slice(5, -1));
console.log(
"str.substr(2, 9) = "
+ str.substr(2, 9));
console.log(
"str.substring(2, 9) = "
+ str.substring(2, 9));
console.log(
"str.split(' ') = "
+ JSON.stringify(str.split('
')));
console.log("str.split('
:
', 4) = " + JSON.stringify(str.split('
:
', 4)));
console.log("str.split('
of
', 4) = " + JSON.stringify(str.split('
of', 4)));
console.log(
""
)
console.log(
"str1.toLocaleLowerCase( ) = "
+ str1.toLocaleLowerCase());
console.log(
"str1.toLocaleUpperCase() = "
+ str1.toLocaleUpperCase());
console.log(
"str1.toLowerCase( ) = "
+ str1.toLowerCase());
console.log(
"str1.toUpperCase() = "
+ str1.toUpperCase());
console.log(
""
)
console.log(
"str1.toString() = "
+ str1.toString());
console.log(
"str1.valueOf( ) = "
+ str1.valueOf());