JavaScript 공통 문자열 메소드
const text = "hello world"
console.log(`text at the index 4 is ${text.charAt(4)}`);
const vowels = "aeiou"
const consonents = "bcdfghjklmnpqrstvwxyz";
const word0 = "Hello world.
const word1 = " Hi world.";
const word2 = " Bye world.";
const alphabets = vowels.concat(consonents);
const sentence = word0.concat(word1, word2);
console.log(alphabets);
console.log(sentence);
const vowels = "aeiou
console.log(vowels.includes("u"));// true
console.log(vowels.includes("z"));// false
const consonents = "bcdfghjklmnpqrstvwxyz"
console.log(consonents.includes("h"))// true
console.log(consonents.includes("a"))// false"
const text = "hello world"
console.log(text.endsWith("d")); // true
console.log(text.endsWith("world")); // true
console.log(text.endsWith("l"));// false;
const alphabets = "abcdefghijklmnpqrstuvwxyza"
console.log(alphabets.indexOf("i")); // output: 8
console.log(alphabets.indexOf("a", 1)); // output: 25
console.log(alphabets.indexOf("o")); // output: -1
const alphabets = "abcdefghijklmnpqrstuvwxyza"
console.log(alphabets.lastIndexOf("i")); // output: 8
console.log(alphabets.lastIndexOf("a")); // output: 25
console.log(alphabets.lastIndexOf("o")); // output: -1;
const text = "The quick brown Bear jumps over the lazy dog."
const regex = /Bear/;
console.log(text.replace("Bear", "goat"));
console.log(text.replace(regex, "lion"));;
const text = "The quick brown fox jumps over the lazy dog."
console.log(text.slice(10)); // output: brown fox jumps over the lazy dog.
console.log(text.slice(10, 20)); // output: brown fox
// if you use negative index then it will count from the end of string
console.log(text.slice(-9, -1)); // output: lazy dog
const text = "The quick brown fox jumps over the lazy dog."
const words = "ab, eb, ib, ob, ub";
console.log(text.split(" "));
console.log(words.split("b"));
const text = "The quick brown fox jumps over the lazy dog."
console.log(text.startsWith("T")); // output: true
console.log(text.startsWith("The")); // output: true
console.log(text.startsWith("A")); // output: false
console.log(text.startsWith("quick")); // output: false;
const text = "The quick brown fox jumps over the lazy dog."
console.log(text.substring(10)); // output: brown fox jumps over the lazy dog.
console.log(text.substring(4, 15)); // output: quick brown
// if you give greater value on the first parameter then it will automatically swap the parameters
console.log(text.substring(15, 4)); // output: quick brown;
const text = "The Quick Brown Fox Jumps Over The Lazy Dog."
console.log(text.toLowerCase());
const text = "The quick brown fox jumps over the lazy dog."
console.log(text.toUpperCase());
const text = " Hello world "
console.log(text.trim()); // output: Hello world;
const text = " Hello world "
console.log(text.trimStart());;
const text = " Hello world "
console.log(text.trimEnd());
Reference
이 문제에 관하여(JavaScript 공통 문자열 메소드), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/jehad_hossain/javascript-common-string-methods-54ok텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)