dev-resources.site
for different kinds of informations.
W3Schools Strings Method With Example
Published at
8/18/2022
Categories
javascript
strings
code
example
Author
developedbyjk
Author
13 person written this
developedbyjk
open
Here are Strings Method that I learned on W3schools
you can copy paste it and check the output and experiment with it
/*
IN JAVASCRIPT
strings are primitve values and they dont have mehthod or properties
BUT
JS consider stings as objects so we can use mehthod and properties with Srings
*/
let text = "Hello World Hello";
//returns the lenght of the text
console.log(text.length);
//extracting the strings from inde
console.log(text.slice(2,5));
//extracting the string if its negative then starts from back
console.log(text.slice(-1,));
//extractin the string : (from, no of amount to extract);
console.log(text.substr(2, 6));
//replace the specific World
console.log(text.replace("Hello","Bye"));
/*
if we have text as >>>>> "Hellow my world you are hello"
: text.replace("Hello","bye"); >> will replace only 1st hello
: to replace all 'Hello' we use : text.replace("/Hello/g","bye");
*/
console.log(text.replace("/Hello/g","bye"));
// or we can use
console.log(text.replaceAll("Hellow", "bye"));
//to upper case
console.log(text.toUpperCase());
// to lower case
console.log(text.toLowerCase());
// now its time to trim so
console.log("TRIMMING " + text.trim());
// adding some before num
//if its nume first we need to convet it into strings
let padnum = "hey bitch";
let convert = padnum.toString();
let padstart = convert.padStart(10,"o");
console.log(padstart);
//SAme you can do with pad end
var name = "bhag";
let outputofname = name.padEnd(50," bhai ");
console.log(outputofname);
//Extracting String Character at specific position
console.log(text.charAt(9));
//Extracting String Character code at specific position
console.log(text.charCodeAt(9));
// you can also do this
console.log(text[9]);
//Converting String to arrays
var convertedtoarray = text.split(" ");
console.log(convertedtoarray[2]);
strings Article's
30 articles in total
trimMiddle() - the missing String trim method
read article
Interpolação, Verbatim String Literals, Múltiplas Linhas – Tudo Sobre Strings no C#
read article
Leetcode — 3110. Score of a String
read article
Tipos Básicos em Kotlin - String Literals
read article
Tipos Básicos em Kotlin - Strings
read article
Quick Zig and C String Conversion Conundrums
read article
Code Smell 261 - DigiCert Underscores
read article
JavaScript: Strings, String Methods, and String Properties
read article
JavaScript: String Template Literals
read article
Top 7 PHP Strings Interview Questions and Answers
read article
Strings in java language
read article
Strings in java language
read article
Unraveling the Power of Strings in Python
read article
What to use instead of `@ember/string`
read article
JS Challenge: Check if a string is a palindrome
read article
5 Interesting Things About Strings in Java
read article
Efficient String Splitting in Go: A Solution for Gophers Dealing with API Responses
read article
Javascript : 12 méthodes essentielles pour les chaînes de caractères
read article
anagram program in java
read article
How to convert String to Integer in java
read article
JS Blog - String Manipulation
read article
Find the Index of the First Occurrence in a String (Naive and KMP Solutions)
read article
In search of subsequence
read article
383. Ransom Note
read article
Split and Join: The Dichotomy of Strings and Arrays
read article
How do Bytes live in Solidity and coexist with Strings?
read article
"str and String in Rust confuses a lot of people in the beginning"
read article
W3Schools Strings Method With Example
currently reading
Javascript Tagalog - Strings
read article
Resources(R.string) in viewModel in Android
read article
Featured ones: