| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/String | [Back] [Original] |
Get to know MDN better
length + += indexOf() substring()
const string1 = "";
const string2 = '';
const string3 = ``;
const string4 = new String("");
2 charAt()
"".charAt(1); // ""
""[1]; // ""
const a = "a";
const b = "b";
if (a < b) {
// true
console.log(`${a} ${b} `);
} else if (a > b) {
console.log(`${a} ${b} `);
} else {
console.log(`${a} ${b} `);
}
function areEqualCaseInsensitive(str1, str2) {
return str1.toUpperCase() === str2.toUpperCase();
}
toUpperCase() toLowerCase() ss toUpperCase() SS toLocaleLowerCase("tr") toLowerCase() I
const areEqualInUpperCase = (str1, str2) =>
str1.toUpperCase() === str2.toUpperCase();
const areEqualInLowerCase = (str1, str2) =>
str1.toLowerCase() === str2.toLowerCase();
areEqualInUpperCase("", "ss"); // true; should be false
areEqualInLowerCase("", "I"); // false; should be true
Intl.Collator API localeCompare() sensitivity "accent" "base"
const areEqual = (str1, str2, locale = "en-US") =>
str1.localeCompare(str2, locale, { sensitivity: "accent" }) === 0;
areEqual("", "ss", "de"); // false
areEqual("", "I", "tr"); // true
localeCompare() strcmp()
JavaScript String Boolean Number
String new
JavaScript
const strPrim = "foo"; //
const strPrim2 = String(1); // "1"
const strPrim3 = String(true); // "true"
const strObj = new String(strPrim); // new String
console.log(typeof strPrim); // "string"
console.log(typeof strPrim2); // "string"
console.log(typeof strPrim3); // "string"
console.log(typeof strObj); // "object"
:
String
String eval() eval String
const s1 = "2 + 2"; //
const s2 = new String("2 + 2"); // String
console.log(eval(s1)); // 4
console.log(eval(s2)); // "2 + 2"
String
String valueOf()
console.log(eval(s2.valueOf())); // 4
undefined "undefined" null "null" true "true" false "false" toString(10) toString(10) TypeError [Symbol.toPrimitive]() "string" toString() valueOf() JavaScript
`${x}` String(x) "" + x
UTF-16 UTF-16 16 UTF-16 216 65536 (BMP) u 4 16
Unicode 65536 UTF-16 16 2 0xD800 0xDFFF 0xD8000xDBFF0xDC00 0xDFFF Unicode \u{xxxxxx} xxxxxx 1-6 16
16
0xD800 0xDBFF 0xDC00 0xDFFF Unicode UTF-16 JavaScript encodeURI() URIError URI UTF-8 well-formed UTF-16 encodeURI() TextEncoder isWellFormed() toWellFormed()
Unicode 1 Unicode <ZWJ> (U+200D)
split("") UTF-16 UTF-16 [Symbol.iterator]() Unicode
"".split(""); // ['\ud83d', '\ude04']; 2
// "Backhand Index Pointing Right: Dark Skin Tone"
[...""]; // ['', '']
// "Backhand Index Pointing Right"
// "Dark skin tone"
// "Family: Man, Boy"
[...""]; // [ '', '', '' ]
// "Man" "Boy" ZWJ
//
[...""]; // [ '', '' ]
// 2 "region indicator" "U" "N"
// 2
String()String String
String.fromCharCode()Unicode
String.fromCodePoint()Unicode
String.raw() String.prototype String
String
length length
String.prototype.at() index UTF-16
String/charAtindex UTF-16 1
String.prototype.charCodeAt()index UTF-16
String.prototype.codePointAt()pos UTF-16
String.prototype.concat()2
String.prototype.endsWith() searchString
String.prototype.includes() searchString
String.prototype.indexOf()searchValue -1
String.prototype.isWellFormed()String.prototype.lastIndexOf()searchValue -1
String.prototype.localeCompare() compareString
String.prototype.match() regexp
String.prototype.matchAll()regexp
String.prototype.normalize()Unicode
String.prototype.padEnd() targetLength
String.prototype.padStart() targetLength
String.prototype.repeat() count
String.prototype.replace()searchFor replaceWith searchFor replaceWith
String.prototype.replaceAll()searchFor replaceWith searchFor replaceWith
String.prototype.search() regexp
String.prototype.slice()String.prototype.split() sep
String.prototype.startsWith() searchString
String.prototype.substr() String/substringString.prototype.toLocaleLowerCase()String.prototype.toLocaleUpperCase()String.prototype.toLowerCase()String.prototype.toString()String.prototype.toUpperCase()String.prototype.toWellFormed()String.prototype.trim()String.prototype.trimEnd()String.prototype.trimStart()String/valueOfString.prototype[Symbol.iterator]():
HTML HTML innerHTML DOM API document.createElement()
String.prototype.anchor() String.prototype.big() <big>String.prototype.blink() <blink>
String.prototype.bold() <b>String.prototype.fixed() <tt>String.prototype.fontcolor() String.prototype.fontsize() String.prototype.italics() <i>String.prototype.link() String.prototype.small() <small>String.prototype.strike() <strike>String.prototype.sub() <sub>String.prototype.sup() <sup>HTML HTML
"</b>".bold(); // <b></b></b>
" anchor()fontcolor()fontsize()link()"
"foo".anchor('"Hello"'); // <a name=""Hello"">foo</a>
String() toString() null undefined
// null undefined
const nullVar = null;
nullVar.toString(); // TypeError: Cannot read properties of null
String(nullVar); // "null"
const undefinedVar = undefined;
undefinedVar.toString(); // TypeError: Cannot read properties of undefined
String(undefinedVar); // "undefined"
| ECMAScript 2027 LanguageSpecification # sec-string-objects |
Stringanchor()at()big()blink()bold()charAt()charCodeAt()codePointAt()concat()endsWith()fixed()fontcolor()fontsize()includes()indexOf()isWellFormed()italics()lastIndexOf()link()localeCompare()match()matchAll()normalize()padEnd()padStart()repeat()replace()replaceAll()search()slice()small()split()startsWith()strike()sub()substr()substring()sup()toLocaleLowerCase()toLocaleUpperCase()toLowerCase()toString()toUpperCase()toWellFormed()trim()trimEnd()trimStart()valueOf()[Symbol.iterator]()Object/Function| Web Proxy Viewer | New URL | Original Page |