JS: String.prototype
What is String.prototype
String.prototype
is the value of the property key "prototype"
of the function String
. 〔see String Object〕
String.hasOwnProperty("prototype")
Type
Type of String.prototype
is Object
.
typeof String.prototype === "object"
String.prototype
is a string object.
console.log( Reflect.apply(Object.prototype.toString, String.prototype, []) === "[object String]", ); console.log(String.prototype.length === 0); console.log("a" + String.prototype + "b" === "ab");
Parent
Parent of String.prototype
is Object.prototype.
Reflect.getPrototypeOf(String.prototype) === Object.prototype
Purpose
Purpose of String.prototype
is to provide methods and properties useful for all string objects.
String.prototype
is the parent of all string objects.
console.log( Reflect.getPrototypeOf(Object("abc")) === String.prototype, ); // Object("abc") turns primitive to object type
Properties
substring
Get character and Unicode
- JS: String.prototype.at
- JS: String.prototype.charAt
- JS: String.prototype.charCodeAt
- JS: String.prototype.codePointAt
join, trim, pad
- JS: String.prototype.concat
- JS: String.prototype.repeat
- JS: String.prototype.trim
- JS: String.prototype.trimStart
- JS: String.prototype.trimEnd
- JS: String.prototype.padStart
- JS: String.prototype.padEnd
Search string
- JS: String.prototype.indexOf
- JS: String.prototype.lastIndexOf
- JS: String.prototype.includes
- JS: String.prototype.startsWith
- JS: String.prototype.endsWith
Search / replace with regex
- JS: String.prototype.search
- JS: String.prototype.match
- JS: String.prototype.matchAll
- JS: String.prototype.replace
Convert to array
Convert letter case
- JS: String.prototype.toLowerCase
String.prototype.toUpperCase
String.prototype.toLocaleLowerCase
String.prototype.toLocaleUpperCase
misc
String.prototype.toString
-
Return the string itself.
String.prototype.valueOf
-
Return the string itself.
String.prototype.localeCompare(str)
-
Return negative, 0, or positive integer, by comparing JS: this (binding) with str, in a locale aware manner.
String.prototype.normalize(form)
-
normalize a string according to Unicode Standard Annex #15 Unicode Normalization Forms.
String.prototype[Symbol.iterator]
-
return the Iterator.
JavaScript. String
- JS: String Overview
- JS: Quote String
- JS: Template String
- JS: String Escape Sequence
- JS: Unicode Escape Sequence
- JS: String Operations
- JS: Iterate String
- JS: String Code Unit
- JS: Count Chars in String 📜
- JS: Tagged Template String
- JS: Regex Functions
- JS: Convert String and Number
- JS: String (class)
- JS: String Constructor
- JS: String.prototype