| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/String | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..
* Some parts of this feature may have varying levels of support.
String , .
:
' ' " " " espaol English portugus "
, , escape-:
\0 |
( NUL) |
\' |
|
\" |
|
\\ |
|
\n |
|
\r |
|
\v |
|
\t |
|
\b |
|
\f |
|
\uXXXX |
- |
\xXX |
Latin-1 |
String :
String(thing) new String(thing)
thing, .
, . , + +=, indexOf(), substring().
. charAt():
return "".charAt(1); // ""
( ECMAScript 5) , :
return ""[1]; // ""
, , , . Object.defineProperty() .
var a = "a";
var b = "b";
if (a < b) {
// true
print(a + " " + b);
} else if (a > b) {
print(a + " " + b);
} else {
print(a + " " + b + " .");
}
localeCompare(), String.
String , JavaScript String ( Boolean Number).
( ) , String ( , new) . JavaScript String, String. , , JavaScript .
var s_prim = "foo";
var s_obj = new String(s_prim);
console.log(typeof s_prim); // 'string'
console.log(typeof s_obj); // 'object'
String eval(). , eval(), ; String , , : . :
var s1 = "2 + 2"; //
var 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
String.length. .
String.fromCharCode(), .
String.fromCodePoint() , .
String.raw() , .
String String Firefox JavaScript 1.6 ( ECMAScript) String, :
var num = 15;
console.log(String.replace(num, /5/, "2"));
:
/*globals define*/
// , String
// ( , )
(function () {
"use strict";
var i,
// ,
// getOwnPropertyNames() JavaScript:
// Object.getOwnPropertyNames(String).filter(function(methodName) {
// return typeof String[methodName] === 'function';
// });
methods = [
"quote",
"substring",
"toLowerCase",
"toUpperCase",
"charAt",
"charCodeAt",
"indexOf",
"lastIndexOf",
"startsWith",
"endsWith",
"trim",
"trimLeft",
"trimRight",
"toLocaleLowerCase",
"toLocaleUpperCase",
"localeCompare",
"match",
"search",
"replace",
"split",
"substr",
"concat",
"slice",
],
methodCount = methods.length,
assignStringGeneric = function (methodName) {
var method = String.prototype[methodName];
String[methodName] = function (arg1) {
return method.apply(arg1, Array.prototype.slice.call(arguments, 1));
};
};
for (i = 0; i < methodCount; i++) {
assignStringGeneric(methods[i]);
}
})();
String toString(), toString(), null undefined. :
var outputStrings = [];
for (var i = 0, n = inputValues.length; i < n; ++i) {
outputStrings.push(String(inputValues[i]));
}
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-string-objects |
This page was last modified on 29 . 2026 . by MDN contributors.
StringString.prototype.anchor()at()String.prototype.big()String.prototype.blink()String.prototype.bold()String.prototype.charAt()String.prototype.charCodeAt()String.prototype.codePointAt()String.prototype.concat()String.prototype.endsWith()String.prototype.fixed()String.prototype.fontcolor()String.prototype.fontsize()String.prototype.includes()String.prototype.indexOf()isWellFormed()String.prototype.italics()String.prototype.lastIndexOf()String.prototype.link()String.prototype.localeCompare()String.prototype.match()String.prototype.matchAll()String.prototype.normalize()String.prototype.padEnd()String.prototype.padStart()String.prototype.repeat()String.prototype.replace()String.prototype.replaceAll()String.prototype.search()String.prototype.slice()String.prototype.small()String.prototype.split()String.prototype.startsWith()String.prototype.strike()String.prototype.sub()String.prototype.substr()String.prototype.substring()String.prototype.sup()String.prototype.toLocaleLowerCase()String.prototype.toLocaleUpperCase()String.prototype.toLowerCase()String.prototype.toString()String.prototype.toUpperCase()toWellFormed()String.prototype.trim()String.prototype.trimRight()String.prototype.trimLeft()String.prototype.valueOf()String.prototype[@@iterator]()Object/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |