javaScript String Function
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript String Function</title>
</head>
<body>
<h1>javaScript String Function</h1>
<script>
var str = "This is a String"
console.log(str);
// indexof me pehla a ka index batayega
var position = str.indexOf('a');
console.log(position);
// lastIndexOf me last ing ka index batayega
position = str.lastIndexOf('ing');
console.log(position);
// iska matlab he 0 index se 4 index tak print kar do is nagitive value bhi support karta he
var substr1 = str.slice(0, 5);
console.log(substr1);
// is bhi uper me diya slice ki tarah hi same he bus yeha par nagative value support nahi karta
var substr2 = str.substring(5, 7);
console.log(substr2);
// same he
var substr3 = str.substr(1, 3);
console.log(substr3);
// string ko replace karne ke liye
// var replace = str.replace('String', "Nazrul");
// console.log(str);
// console.log(replace);
// uppercase And lowerCase function
// var lower = str.toUpperCase();
// console.log(lower);
// var uppercase = str.toLowerCase();
// console.log(uppercase)
// console.log(str.toUpperCase());
// console.log(str.toLowerCase());
// string ko jorne ke liye concat method
var newString=str.concat('new concat string');
console.log(newString);
// last aur frist ke white space ko trimp kar ne ke liye
var whiteSpace=" this is white space string ";
console.log(whiteSpace);
console.log(whiteSpace.trim());
// 2 number ke index me konsa charTar he use retarn karo
var char2=str.charAt(2);
console.log(char2);
var codeChar = str.charCodeAt(2)
console.log(codeChar);
// aur slice kar ne method
console.log(str[3])
</script>
</body>
</html>
Comments
Post a Comment