file stringlengths 16 94 | text stringlengths 32 24.4k | vector list |
|---|---|---|
javascript/reference/global_objects/asyncfunction/index.md | JavaScript - Global Objects - AsyncFunction - Constructor:
- `AsyncFunction()`: Creates a new `AsyncFunction` object. | [
-0.7284829616546631,
0.08897200226783752,
-0.9236728549003601,
0.32553955912590027,
-0.7599883079528809,
-1.3276875019073486,
-0.16322682797908783,
1.2784898281097412,
0.08124173432588577,
0.19297051429748535,
-0.6373720765113831,
-0.6844741702079773,
0.06195648014545441,
0.326522886753082... |
javascript/reference/global_objects/asyncfunction/index.md | JavaScript - Global Objects - AsyncFunction - Instance properties:
Also inherits instance properties from its parent `Function`.
These properties are defined on `AsyncFunction.prototype` and shared by all `AsyncFunction` instances.
- `AsyncFunction.prototype.constructor`: The constructor function that created the in... | [
-0.6103432178497314,
0.15088316798210144,
-0.5495919585227966,
0.6711279153823853,
-0.3279348909854889,
-2.1415019035339355,
0.2654987871646881,
0.8416507840156555,
0.5523886680603027,
0.0880797803401947,
-0.8735776543617249,
-0.3344011902809143,
-0.5624972581863403,
0.27021315693855286,
... |
javascript/reference/global_objects/asyncfunction/index.md | JavaScript - Global Objects - AsyncFunction - Instance methods:
Inherits instance methods from its parent `Function`. | [
-0.12099235504865646,
-0.09146174043416977,
-0.7661988139152527,
0.01754222996532917,
-0.8248210549354553,
-1.9763613939285278,
0.8124498724937439,
0.9442974328994751,
-0.09241043031215668,
-0.7935965061187744,
-0.7945170998573303,
-0.2624034881591797,
-0.6883163452148438,
0.76474738121032... |
javascript/reference/global_objects/asyncfunction/asyncfunction/index.md | JavaScript - Global Objects - AsyncFunction:
Warning: The arguments passed to this constructor are dynamically parsed and executed as JavaScript. APIs like this are known as injection sinks, and are potentially a vector for cross-site-scripting (XSS) attacks. You can mitigate this risk by always passing `TrustedScript... | [
-0.7500618696212769,
0.08543090522289276,
-0.9679320454597473,
0.9623417854309082,
-0.3097439706325531,
-1.857059359550476,
0.16787102818489075,
0.20092904567718506,
-0.07565956562757492,
0.7632661461830139,
-0.5300487279891968,
0.3452877402305603,
-0.0640861913561821,
-0.05435003340244293... |
javascript/reference/global_objects/asyncfunction/asyncfunction/index.md | JavaScript - Global Objects - AsyncFunction - Syntax:
Example:
new AsyncFunction(functionBody)
new AsyncFunction(arg1, functionBody)
new AsyncFunction(arg1, arg2, functionBody)
new AsyncFunction(arg1, arg2, /* …, */ argN, functionBody)
AsyncFunction(functionBody)
AsyncFunction(arg1, functionBody)
AsyncFunction(arg1,... | [
-0.2681517004966736,
0.37983402609825134,
-0.7567416429519653,
0.07605864852666855,
-0.6211107969284058,
-2.0096933841705322,
-0.5233420729637146,
0.9528535008430481,
0.12208982557058334,
-0.18972881138324738,
-0.773006796836853,
-0.9812931418418884,
-0.27057141065597534,
0.65986168384552,... |
javascript/reference/global_objects/asyncfunction/asyncfunction/index.md | JavaScript - Global Objects - AsyncFunction - Syntax - Parameters:
See `Function()`. | [
-0.0932195857167244,
0.34406888484954834,
-0.8663665056228638,
-0.18726380169391632,
-0.9639933109283447,
-1.7412407398223877,
0.3916391432285309,
0.7740632891654968,
0.1812652051448822,
-0.03765799105167389,
-0.37856265902519226,
-0.2719416916370392,
0.41370558738708496,
0.795988202095031... |
javascript/reference/global_objects/asyncfunction/asyncfunction/index.md | JavaScript - Global Objects - AsyncFunction - Examples:
Note that these examples omit the use of trusted types for brevity. For code showing the recommended approach, see Using `TrustedScript` in `eval()`. | [
-1.3011469841003418,
0.7102591395378113,
-0.7645429968833923,
0.46807771921157837,
-0.6131129860877991,
-1.1763814687728882,
1.2721260786056519,
-0.08632850646972656,
-0.7838969230651855,
0.5096592903137207,
-0.17306017875671387,
0.16391348838806152,
0.05720270797610283,
-0.012343270704150... |
javascript/reference/global_objects/asyncfunction/asyncfunction/index.md | JavaScript - Global Objects - AsyncFunction - Examples - Creating an async function from an AsyncFunction() constructor:
Example:
function resolveAfter2Seconds(x) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(x);
}, 2000);
});
}
const AsyncFunction = async function () {}.constructo... | [
-0.7617475986480713,
0.8467397689819336,
-0.0942169800400734,
0.6823145151138306,
-0.3617071211338043,
-0.4478963613510132,
-0.09908686578273773,
0.37596914172172546,
0.004856366664171219,
0.016759708523750305,
-0.06260301917791367,
0.32543447613716125,
0.04325757548213005,
0.1700423359870... |
javascript/reference/global_objects/unescape/index.md | JavaScript - Global Objects - unescape:
Deprecated: This feature is no longer recommended.
Note: `unescape()` is a non-standard function implemented by browsers and was only standardized for cross-engine compatibility. It is not required to be implemented by all JavaScript engines and may not work everywhere. Use `de... | [
-0.9042633175849915,
-0.32028311491012573,
-1.0519014596939087,
-0.176981121301651,
-0.2624934911727905,
-1.3594410419464111,
0.7737293839454651,
-0.03288499638438225,
-0.61320561170578,
-0.2035774141550064,
-0.7396867275238037,
-0.17085310816764832,
0.1683586686849594,
0.28225427865982056... |
javascript/reference/global_objects/unescape/index.md | JavaScript - Global Objects - unescape - Syntax:
Example:
unescape(str) | [
-0.6227026581764221,
0.4190089702606201,
-1.0466467142105103,
-0.5762915015220642,
-0.6045292615890503,
-1.5163060426712036,
0.05470772087574005,
0.6380442976951599,
-0.20798952877521515,
-0.07289040088653564,
-0.35725802183151245,
-0.07257393002510071,
-0.027145294472575188,
-0.2063639760... |
javascript/reference/global_objects/unescape/index.md | JavaScript - Global Objects - unescape - Syntax - Parameters:
- `str`: A string to be decoded. | [
-0.2577663064002991,
0.055156160145998,
-0.9715453386306763,
-0.7930612564086914,
0.029466504231095314,
-1.4491838216781616,
-0.1150142252445221,
0.08244367688894272,
0.21426595747470856,
0.6429415941238403,
-0.7050104737281799,
-0.04859164357185364,
-0.12377001345157623,
0.644751131534576... |
javascript/reference/global_objects/unescape/index.md | JavaScript - Global Objects - unescape - Syntax - Return value:
A new string in which certain characters have been unescaped. | [
-0.29835045337677,
-0.2648228704929352,
-0.8207811117172241,
-0.49107635021209717,
-0.14400167763233185,
-1.7726671695709229,
0.8853487968444824,
1.2774935960769653,
-0.6609750390052795,
0.343841016292572,
-0.49470001459121704,
0.16632020473480225,
-0.5041370987892151,
0.8261789083480835,
... |
javascript/reference/global_objects/unescape/index.md | JavaScript - Global Objects - unescape - Description:
`unescape()` is a function property of the global object.
The `unescape()` function replaces any escape sequence with the character that it represents. Specifically, it replaces any escape sequence of the form `%XX` or `%uXXXX` (where `X` represents one hexadecima... | [
-1.695745825767517,
-0.2906622588634491,
-1.5476783514022827,
-0.5276838541030884,
-0.2497919499874115,
-1.1786420345306396,
0.3986748158931732,
0.3955768048763275,
-0.05970931053161621,
-0.5440781116485596,
-0.42900025844573975,
-0.015436967834830284,
-0.4714520275592804,
0.01422309782356... |
javascript/reference/global_objects/unescape/index.md | JavaScript - Global Objects - unescape - Examples - Using unescape():
Example:
unescape("abc123"); // "abc123"
unescape("%E4%F6%FC"); // "äöü"
unescape("%u0107"); // "ć" | [
-0.650776743888855,
0.674965500831604,
-0.6619493365287781,
-0.0829782634973526,
-0.1560186743736267,
-1.0832401514053345,
0.5322839617729187,
0.2174900770187378,
-0.5897691249847412,
0.09780872613191605,
-0.16824889183044434,
-0.20353804528713226,
0.062375400215387344,
-0.2892652451992035... |
javascript/reference/global_objects/string/iswellformed/index.md | JavaScript - Global Objects - String - isWellFormed:
The `isWellFormed()` method of `String` values returns a boolean indicating whether this string contains any lone surrogates. | [
-1.5206438302993774,
0.42422547936439514,
-0.9411239624023438,
-0.23096315562725067,
-0.6805100440979004,
-2.016887903213501,
1.5231674909591675,
0.6494114995002747,
-0.9795222282409668,
-0.07092881202697754,
-1.187865138053894,
-0.1558314710855484,
0.49029526114463806,
-0.2445473521947860... |
javascript/reference/global_objects/string/iswellformed/index.md | JavaScript - Global Objects - String - isWellFormed - Syntax:
Example:
isWellFormed() | [
-0.3613448739051819,
0.7614274024963379,
-0.6167256236076355,
-0.3925459086894989,
-0.9002789258956909,
-2.1937925815582275,
1.051967978477478,
0.3904842734336853,
-0.6237251162528992,
-0.2037225365638733,
-0.9280580282211304,
-0.3330444097518921,
-0.08599351346492767,
-0.16921861469745636... |
javascript/reference/global_objects/string/iswellformed/index.md | JavaScript - Global Objects - String - isWellFormed - Syntax - Parameters:
None. | [
-0.48879992961883545,
0.5470330715179443,
-0.7834864854812622,
-0.7698872089385986,
-0.6595715284347534,
-1.7760181427001953,
0.9737935662269592,
0.44991418719291687,
-0.7514507174491882,
-0.11552723497152328,
-1.0173479318618774,
-0.7886435985565186,
0.2276914119720459,
0.0045428462326526... |
javascript/reference/global_objects/string/iswellformed/index.md | JavaScript - Global Objects - String - isWellFormed - Syntax - Return value:
Returns `true` if this string does not contain any lone surrogates, `false` otherwise. | [
-1.1477985382080078,
0.6572556495666504,
-0.3003765046596527,
-0.5843018889427185,
-1.0777078866958618,
-1.3577824831008911,
1.3169918060302734,
0.3784217834472656,
-1.0815366506576538,
-0.11148346960544586,
-1.01748526096344,
-0.47405511140823364,
0.3284388482570648,
-0.11524461209774017,... |
javascript/reference/global_objects/string/iswellformed/index.md | JavaScript - Global Objects - String - isWellFormed - Description:
Strings in JavaScript are UTF-16 encoded. UTF-16 encoding has the concept of surrogate pairs, which is introduced in detail in the UTF-16 characters, Unicode code points, and grapheme clusters section.
`isWellFormed()` allows you to test whether a str... | [
-1.0420573949813843,
0.904686450958252,
-0.5398827195167542,
-0.3326134979724884,
0.28659191727638245,
-0.9643694162368774,
1.5699912309646606,
0.1493392139673233,
-0.1526343822479248,
-0.12706974148750305,
-0.8852009773254395,
0.2560793161392212,
-0.12363244593143463,
-0.3966851532459259,... |
javascript/reference/global_objects/string/iswellformed/index.md | JavaScript - Global Objects - String - isWellFormed - Examples - Using isWellFormed():
Example:
const strings = [
// Lone leading surrogate
"ab\uD800",
"ab\uD800c",
// Lone trailing surrogate
"\uDFFFab",
"c\uDFFFab",
// Well-formed
"abc",
"ab\uD83D\uDE04c",
];
for (const str of strings) {
console... | [
-0.4652312099933624,
0.7464020848274231,
-0.3671343922615051,
-0.932199239730835,
-0.4995284378528595,
-1.5924415588378906,
0.12627163529396057,
0.4134991466999054,
-0.24813395738601685,
-0.03622912988066673,
-0.38760995864868164,
-0.3919597566127777,
0.09987819194793701,
0.215493574738502... |
javascript/reference/global_objects/string/iswellformed/index.md | JavaScript - Global Objects - String - isWellFormed - Examples - Avoiding errors in encodeURI():
`encodeURI` throws an error if the string passed is not well-formed. This can be avoided by using `isWellFormed()` to test the string before passing it to `encodeURI()`.
Example:
const illFormed = "https://example.com/se... | [
-0.12694032490253448,
1.0010790824890137,
-0.8994609117507935,
-0.15513603389263153,
-1.1351014375686646,
-1.013439416885376,
0.07594922930002213,
0.20200300216674805,
-1.0803158283233643,
0.1424010992050171,
-0.7471120953559875,
-0.640058696269989,
0.022876504808664322,
-0.346018522977829... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf:
The `indexOf()` method of `String` values searches this string and returns the index of the first occurrence of the specified substring. It takes an optional starting position and returns the first occurrence of the specified substring at an index greater than or equal t... | [
-1.4050228595733643,
-1.1533658504486084,
-0.758202314376831,
0.455223947763443,
-0.06357908248901367,
-1.1639134883880615,
0.2922738790512085,
-0.38446763157844543,
0.5515767335891724,
-0.12669360637664795,
-1.3232851028442383,
-0.396892249584198,
-0.3964008688926697,
0.3013359308242798,
... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Syntax:
Example:
indexOf(searchString)
indexOf(searchString, position) | [
-1.2147105932235718,
-0.6821632385253906,
-0.6085260510444641,
-0.28113749623298645,
-0.19424808025360107,
-1.4030463695526123,
0.06155863404273987,
0.4708716869354248,
0.5314407348632812,
-0.7903321981430054,
-0.7690337896347046,
-0.16496342420578003,
-0.33233439922332764,
0.3469778895378... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Syntax - Parameters:
- `searchString`: Substring to search for. All values are coerced to strings, so omitting it or passing `undefined` causes `indexOf()` to search for the string `"undefined"`, which is rarely what you want.
- `position` (optional): The method returns... | [
0.07397978752851486,
0.2845582664012909,
-0.4893234074115753,
0.9285328984260559,
0.4861098825931549,
-0.25712406635284424,
0.45819079875946045,
-0.03145739808678627,
-0.3894236981868744,
-0.1476302295923233,
-0.8458443284034729,
-0.32011887431144714,
0.2711764872074127,
0.3155458867549896... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Syntax - Return value:
The index of the first occurrence of `searchString` found, or `-1` if not found. | [
-1.063978672027588,
-0.6338713765144348,
-0.6007757782936096,
0.41664445400238037,
-0.11481788009405136,
-0.6995099186897278,
1.1938101053237915,
0.6983898282051086,
-0.3247123062610626,
-0.3715057075023651,
-0.6603479981422424,
-0.3674217462539673,
-0.4571716785430908,
0.5601350665092468,... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Syntax - Return value - Return value when using an empty search string:
Searching for an empty search string produces strange results. With no second argument, or with a second argument whose value is less than the calling string's length, the return value is the same a... | [
-1.3062829971313477,
-0.5005563497543335,
-0.3769775629043579,
0.5403212904930115,
-0.12148578464984894,
-1.6288725137710571,
0.7897462844848633,
0.2397080957889557,
-0.14102666079998016,
0.10811229795217514,
-0.5697329044342041,
-0.3893773853778839,
-0.004374532960355282,
0.35741829872131... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Description:
Strings are zero-indexed: The index of a string's first character is `0`, and the index of a string's last character is the length of the string minus 1.
Example:
"Blue Whale".indexOf("Blue"); // returns 0
"Blue Whale".indexOf("Wale"); // returns -1
"Blu... | [
-1.1650917530059814,
-0.30095043778419495,
-0.25924792885780334,
-0.019229445606470108,
0.6776893734931946,
-1.2734295129776,
0.5926485061645508,
0.28875699639320374,
0.17115572094917297,
0.01930222101509571,
-0.9866814613342285,
-0.43617770075798035,
-0.24816694855690002,
-0.0976878628134... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Description - Checking occurrences:
When checking if a specific substring occurs within a string, the correct way to check is test whether the return value is `-1`:
Example:
"Blue Whale".indexOf("Blue") !== -1; // true; found 'Blue' in 'Blue Whale'
"Blue Whale".indexO... | [
-1.0687599182128906,
-0.43843570351600647,
-0.6241113543510437,
0.45397308468818665,
0.048941850662231445,
-0.6185237169265747,
0.9268765449523926,
0.09009139239788055,
-0.4411020278930664,
0.2183811515569687,
-0.7442507147789001,
-0.7531388401985168,
0.19134576618671417,
0.515026569366455... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Examples - Using indexOf():
The following example uses `indexOf()` to locate substrings in the string `"Brave new world"`.
Example:
const str = "Brave new world";
console.log(str.indexOf("w")); // 8
console.log(str.indexOf("new")); // 6 | [
-0.8546387553215027,
-0.5983638763427734,
-0.6360495090484619,
0.7139894366264343,
-0.10263180732727051,
-1.2180413007736206,
0.6044881939888,
-0.7306115031242371,
0.6127962470054626,
-0.2252660095691681,
-1.199065089225769,
-0.48651382327079773,
-0.014301689341664314,
0.34895265102386475,... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Examples - indexOf() and case-sensitivity:
The following example defines two string variables.
The variables contain the same string, except that the second string contains uppercase letters. The first `console.log()` method displays `19`. But because the `indexOf()` m... | [
-1.5583975315093994,
-0.9356246590614319,
-0.8214234113693237,
0.710564374923706,
0.11110562831163406,
-1.6699265241622925,
-0.041787900030612946,
0.7141820788383484,
0.4150427281856537,
-0.17845486104488373,
-0.007713606581091881,
-0.24757333099842072,
-0.5844666957855225,
-0.191786766052... |
javascript/reference/global_objects/string/indexof/index.md | JavaScript - Global Objects - String - indexOf - Examples - Using indexOf() to count occurrences of a letter in a string:
The following example sets `count` to the number of occurrences of the letter `e` in the string `str`:
Example:
const str = "To be, or not to be, that is the question.";
let count = 0;
let positi... | [
-1.0669301748275757,
-0.4297805428504944,
-0.446975976228714,
0.5586123466491699,
0.2431214302778244,
-1.5785086154937744,
0.25826194882392883,
-0.2748955488204956,
0.4100012183189392,
0.05136684328317642,
-0.5871373414993286,
-0.19251340627670288,
-0.12158041447401047,
0.20596586167812347... |
javascript/reference/global_objects/string/replaceall/index.md | JavaScript - Global Objects - String - replaceAll:
The `replaceAll()` method of `String` values returns a new string with all matches of a `pattern` replaced by a `replacement`. The `pattern` can be a string or a `RegExp`, and the `replacement` can be a string or a function to be called for each match. The original st... | [
-1.029729962348938,
-0.30731675028800964,
-0.6921047568321228,
0.08712742477655411,
-0.1374732404947281,
-2.7375545501708984,
0.5952228307723999,
0.5663055777549744,
-0.22566430270671844,
-0.9375376105308533,
-0.8888643383979797,
0.058707091957330704,
-0.5216959714889526,
0.808412969112396... |
javascript/reference/global_objects/string/replaceall/index.md | JavaScript - Global Objects - String - replaceAll - Syntax:
Example:
replaceAll(pattern, replacement) | [
-0.3739582300186157,
0.010541175492107868,
-0.7144612669944763,
-0.07271485775709152,
-1.0041325092315674,
-2.7578282356262207,
0.5057724714279175,
0.9463339447975159,
-0.10892067849636078,
-1.0336133241653442,
-0.5857736468315125,
-0.2459225207567215,
-0.4430697560310364,
0.39911723136901... |
javascript/reference/global_objects/string/replaceall/index.md | JavaScript - Global Objects - String - replaceAll - Syntax - Parameters:
- `pattern`: Can be a string or an object with a `Symbol.replace` method — the typical example being a regular expression. Any value that doesn't have the `Symbol.replace` method will be coerced to a string. If `pattern` is a regex, then it must ... | [
-0.23883913457393646,
0.07596965879201889,
-0.6172069311141968,
-0.27522405982017517,
-0.2194676697254181,
-2.6649036407470703,
0.32326197624206543,
1.0533816814422607,
0.3840356767177582,
-1.0160351991653442,
-1.041281819343567,
-0.1955701857805252,
-0.571880578994751,
0.3029620051383972,... |
javascript/reference/global_objects/string/replaceall/index.md | JavaScript - Global Objects - String - replaceAll - Syntax - Return value:
A new string, with all matches of a pattern replaced by a replacement. | [
-0.38551267981529236,
-0.08908278495073318,
-0.5801023840904236,
-0.32650676369667053,
-0.534247100353241,
-1.8847709894180298,
0.46158039569854736,
0.7712611556053162,
-0.12586931884288788,
-0.5026702284812927,
-0.7610051035881042,
0.055151764303445816,
-0.39381271600723267,
1.43895447254... |
javascript/reference/global_objects/string/replaceall/index.md | JavaScript - Global Objects - String - replaceAll - Syntax - Exceptions:
- `TypeError`: Thrown if the `pattern` is a regex that does not have the global (`g`) flag set (its `flags` property does not contain `"g"`). | [
-0.87208491563797,
0.3368833363056183,
-0.48866286873817444,
0.112975113093853,
-0.31008991599082947,
-2.4035778045654297,
0.3285166919231415,
1.027193546295166,
-0.6145026087760925,
-0.6941991448402405,
-0.8417773246765137,
-0.4822539985179901,
-0.2711276412010193,
0.029472164809703827,
... |
javascript/reference/global_objects/string/replaceall/index.md | JavaScript - Global Objects - String - replaceAll - Description:
This method does not mutate the string value it's called on. It returns a new string.
Unlike `replace()`, this method replaces all occurrences of a string, not just the first one. While it is also possible to use `replace()` with a global regex dynamica... | [
-0.10830648243427277,
0.17538970708847046,
0.03654923662543297,
0.5275291204452515,
0.8073320984840393,
-1.27715265750885,
-0.025789175182580948,
0.6001275777816772,
-0.39870166778564453,
-0.2562618553638458,
-0.677927553653717,
0.4031440019607544,
-0.6826546788215637,
0.058655206114053726... |
javascript/reference/global_objects/string/replaceall/index.md | JavaScript - Global Objects - String - replaceAll - Examples - Using replaceAll():
Example:
"aabbcc".replaceAll("b", ".");
// 'aa..cc' | [
-0.6640419363975525,
0.39599373936653137,
-0.4010210633277893,
0.15713566541671753,
-0.5807494521141052,
-2.246356964111328,
0.5389647483825684,
0.28419265151023865,
-0.026723597198724747,
-0.8036880493164062,
-0.2550968527793884,
-0.43196043372154236,
-0.04745226725935936,
0.4403471350669... |
javascript/reference/global_objects/string/replaceall/index.md | JavaScript - Global Objects - String - replaceAll - Examples - Non-global regex throws:
When using a regular expression search value, it must be global. This won't work:
Example:
"aabbcc".replaceAll(/b/, ".");
// TypeError: replaceAll must be called with a global RegExp
This will work:
Example:
"aabbcc".replaceAl... | [
-0.35161885619163513,
0.8344873189926147,
-0.6207689642906189,
-0.25829386711120605,
-0.3040581941604614,
-1.3049507141113281,
-0.25985226035118103,
0.11227048933506012,
-0.533755362033844,
-0.8088514804840088,
-0.4603027403354645,
-0.19835956394672394,
0.3476780354976654,
-0.0991396382451... |
javascript/reference/global_objects/string/startswith/index.md | JavaScript - Global Objects - String - startsWith:
The `startsWith()` method of `String` values determines whether this string begins with the characters of a specified string, returning `true` or `false` as appropriate.
Example:
const str = "Saturday night plans";
console.log(str.startsWith("Sat"));
// Expected ou... | [
-1.3052520751953125,
-0.3584011495113373,
-0.1914178729057312,
0.11061882972717285,
-0.8590876460075378,
-1.8226566314697266,
0.6384281516075134,
0.05294066667556763,
0.1454775184392929,
-0.16087348759174347,
-0.7805922031402588,
-0.07555068284273148,
-0.050879620015621185,
0.0698608830571... |
javascript/reference/global_objects/string/startswith/index.md | JavaScript - Global Objects - String - startsWith - Syntax:
Example:
startsWith(searchString)
startsWith(searchString, position) | [
-1.020184874534607,
-0.057990025728940964,
-0.013575679622590542,
-0.10014063119888306,
-1.2939050197601318,
-1.3271188735961914,
-0.027711207047104836,
0.24230380356311798,
0.33213651180267334,
-0.6106088161468506,
-0.2059727907180786,
-0.05412143096327782,
-0.13206864893436432,
0.1277307... |
javascript/reference/global_objects/string/startswith/index.md | JavaScript - Global Objects - String - startsWith - Syntax - Parameters:
- `searchString`: The characters to be searched for at the start of this string. Cannot be a regex. All values that are not regexes are coerced to strings, so omitting it or passing `undefined` causes `startsWith()` to search for the string `"und... | [
-1.1375458240509033,
-0.0029169288463890553,
-0.5145758390426636,
-0.31295275688171387,
-0.3635478913784027,
-1.0323193073272705,
0.8261426687240601,
-0.3959985375404358,
0.3439558446407318,
-0.47543102502822876,
-0.8281951546669006,
-0.20644761621952057,
-0.34317201375961304,
0.0549042299... |
javascript/reference/global_objects/string/startswith/index.md | JavaScript - Global Objects - String - startsWith - Syntax - Return value:
`true` if the given characters are found at the beginning of the string, including when `searchString` is an empty string; otherwise, `false`. | [
-1.2092701196670532,
-0.10095266997814178,
-0.11108133941888809,
-0.2454538196325302,
-0.5951071977615356,
-1.6802468299865723,
1.4921592473983765,
0.027799485251307487,
-0.46177828311920166,
-0.06681539863348007,
-0.6354987621307373,
-0.3186868131160736,
0.18640916049480438,
0.24042633175... |
javascript/reference/global_objects/string/startswith/index.md | JavaScript - Global Objects - String - startsWith - Syntax - Exceptions:
- `TypeError`: Thrown if `searchString` is a regex. | [
-1.1925928592681885,
0.3866065442562103,
-0.32547616958618164,
-0.06867475807666779,
-0.5833069086074829,
-0.9246696829795837,
-0.12235652655363083,
0.6384579539299011,
-0.4170389771461487,
-0.6907097101211548,
-0.7281059622764587,
-0.6269649267196655,
0.0067746867425739765,
-0.41114902496... |
javascript/reference/global_objects/string/startswith/index.md | JavaScript - Global Objects - String - startsWith - Description:
This method lets you determine whether or not a string begins with another string. This method is case-sensitive. | [
-1.061318039894104,
-0.03801218047738075,
0.01465641614049673,
0.07084441184997559,
-0.8162400126457214,
-1.5502634048461914,
0.6353737711906433,
0.4577428996562958,
0.5950056314468384,
0.12613016366958618,
-1.1055861711502075,
-0.1876593679189682,
-0.05821307748556137,
0.3782590329647064,... |
javascript/reference/global_objects/string/startswith/index.md | JavaScript - Global Objects - String - startsWith - Examples - Using startsWith():
Example:
const str = "To be, or not to be, that is the question.";
console.log(str.startsWith("To be")); // true
console.log(str.startsWith("not to be")); // false
console.log(str.startsWith("not to be", 10)); // true | [
-0.47640010714530945,
0.1231895238161087,
0.3797842264175415,
0.6999052166938782,
-0.9061658978462219,
-1.3311474323272705,
0.1373548060655594,
0.10866245627403259,
0.46246030926704407,
-0.11039654910564423,
-0.2324942946434021,
0.03609365224838257,
-0.3961154520511627,
-0.2937183976173401... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll:
The `matchAll()` method of `String` values returns an iterator of all results matching this string against a regular expression, including capturing groups.
Example:
const regexp = /t(e)(st(\d?))/g;
const str = "test1test2";
const array = [...str.matchAll(regexp)];
... | [
-0.8112751245498657,
-0.264486700296402,
-1.1048232316970825,
0.046428389847278595,
0.15863360464572906,
-1.194891095161438,
-0.00722922058776021,
0.43636077642440796,
-0.22964957356452942,
0.516986608505249,
-1.1012320518493652,
-0.15939649939537048,
0.3867054581642151,
0.3196605443954468... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll - Syntax:
Example:
matchAll(regexp) | [
-0.3518369793891907,
0.26131671667099,
-0.7214582562446594,
-0.7285895347595215,
-0.8419278264045715,
-1.4981889724731445,
0.6404936909675598,
0.46191784739494324,
0.1922319084405899,
-0.33471086621284485,
-0.9991552233695984,
-0.13489298522472382,
0.13710927963256836,
0.5072147846221924,
... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll - Syntax - Parameters:
- `regexp`: A regular expression object, or any object that has a `Symbol.matchAll` method. If `regexp` is not a `RegExp` object and does not have a `Symbol.matchAll` method, it is implicitly converted to a `RegExp` by using `new RegExp(regexp, 'g'... | [
-0.5023488998413086,
-0.07900720834732056,
-0.46561652421951294,
-0.5443441271781921,
-0.6169236302375793,
-1.27988862991333,
0.10005080699920654,
0.956416130065918,
0.517928957939148,
-0.5893495678901672,
-0.9384484887123108,
-0.10931743681430817,
0.15783429145812988,
0.8168678283691406,
... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll - Syntax - Return value:
An iterable iterator object (which is not restartable) of matches or an empty iterator if no matches are found. Each value yielded by the iterator is an array with the same shape as the return value of `RegExp.prototype.exec()`. | [
-0.5942198634147644,
0.13349397480487823,
-0.27626532316207886,
0.21621757745742798,
-0.3334650993347168,
-1.0073387622833252,
0.527940034866333,
1.0361026525497437,
-0.46134114265441895,
0.16464188694953918,
-0.9254453778266907,
0.35757309198379517,
-0.1112557053565979,
0.9980932474136353... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll - Syntax - Exceptions:
- `TypeError`: Thrown if the `regexp` is a regex that does not have the global (`g`) flag set (its `flags` property does not contain `"g"`). | [
-0.9113717675209045,
0.36102157831192017,
-0.4393630027770996,
-0.24561923742294312,
-0.3263898491859436,
-1.8022701740264893,
0.21891140937805176,
0.9354697465896606,
-0.47454917430877686,
-0.4289393126964569,
-0.7821361422538757,
-0.4887641668319702,
-0.0007116226479411125,
0.03636590018... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll - Description:
The implementation of `String.prototype.matchAll` doesn't do much other than calling the `Symbol.matchAll` method of the argument with the string as the first parameter (apart from the extra input validation that the regex is global). The actual implementa... | [
-0.36305955052375793,
0.3529512286186218,
-0.28868821263313293,
-0.255481481552124,
-0.25940221548080444,
-1.577417016029358,
1.064255714416504,
0.5290940999984741,
0.10098475217819214,
-0.18802961707115173,
-1.8301854133605957,
-0.16167470812797546,
0.6250295639038086,
0.0861283466219902,... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll - Examples - Regexp.prototype.exec() and matchAll():
Without `matchAll()`, it's possible to use calls to `regexp.exec()` (and regexes with the `g` flag) in a loop to obtain all the matches:
Example:
const regexp = /foo[a-z]*/g;
const str = "table football, foosball";
l... | [
-0.7737922668457031,
0.32900160551071167,
-0.8751915693283081,
0.32439830899238586,
0.6881940364837646,
-0.13405437767505646,
-0.26414310932159424,
-0.004690359812229872,
-0.6452739834785461,
-0.05452222377061844,
0.09059492498636246,
-0.15330736339092255,
-0.6535815000534058,
0.6863337159... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll - Examples - Better access to capturing groups (than String.prototype.match()):
Another compelling reason for `matchAll` is the improved access to capture groups.
Capture groups are ignored when using `match()` with the global `g` flag:
Example:
const regexp = /t(e)(s... | [
-0.47305452823638916,
-0.25683924555778503,
-1.344730257987976,
-0.40291017293930054,
0.28570544719696045,
-1.5309436321258545,
-0.010852995328605175,
0.2647918462753296,
-0.395942360162735,
0.6140115857124329,
-1.2640630006790161,
-0.9161438941955566,
-0.08243291825056076,
0.6177474260330... |
javascript/reference/global_objects/string/matchall/index.md | JavaScript - Global Objects - String - matchAll - Examples - Using matchAll() with a non-RegExp implementing `[Symbol.matchAll]()`:
If an object has a `Symbol.matchAll` method, it can be used as a custom matcher. The return value of `Symbol.matchAll` becomes the return value of `matchAll()`.
Example:
const str = "Hm... | [
-0.22751879692077637,
0.08157747983932495,
-0.23278822004795074,
0.237849161028862,
-0.15973971784114838,
-0.8346187472343445,
1.2853270769119263,
0.5938613414764404,
0.15712657570838928,
0.2229093611240387,
-0.9754116535186768,
0.459797203540802,
-0.20681431889533997,
0.1308615356683731,
... |
javascript/reference/global_objects/string/tolocaleuppercase/index.md | JavaScript - Global Objects - String - toLocaleUpperCase:
The `toLocaleUpperCase()` method of `String` values returns this string converted to upper case, according to any locale-specific case mappings.
Example:
const city = "istanbul";
console.log(city.toLocaleUpperCase("en-US"));
// Expected output: "ISTANBUL"
c... | [
-0.6652740836143494,
0.22038307785987854,
-0.34380385279655457,
0.5345010757446289,
0.3814387917518616,
-1.0669317245483398,
0.5335918068885803,
0.7001668214797974,
-0.3633349537849426,
0.2026086449623108,
-0.4551485776901245,
1.404665231704712,
-0.05394956097006798,
0.464444637298584,
-... |
javascript/reference/global_objects/string/tolocaleuppercase/index.md | JavaScript - Global Objects - String - toLocaleUpperCase - Syntax:
Example:
toLocaleUpperCase()
toLocaleUpperCase(locales) | [
-0.7609997391700745,
0.4278820753097534,
-0.14357690513134003,
0.20561808347702026,
-0.19854754209518433,
-1.9458510875701904,
0.7825953364372253,
0.9198716282844543,
-0.6780876517295837,
-0.5081645250320435,
-0.5057054162025452,
1.0031516551971436,
-0.13088075816631317,
0.3877561688423157... |
javascript/reference/global_objects/string/tolocaleuppercase/index.md | JavaScript - Global Objects - String - toLocaleUpperCase - Syntax - Parameters:
- `locales` (optional): A string with a `BCP 47 language tag`, or an array of such strings. Indicates the locale to be used to convert to upper case according to any locale-specific case mappings. For the general form and interpretation of... | [
-1.1765172481536865,
0.16238337755203247,
-0.12040167301893234,
0.5699783563613892,
0.5141473412513733,
-1.910797357559204,
1.7554043531417847,
0.1346716433763504,
-0.3524041771888733,
-0.04349216818809509,
-0.31878232955932617,
0.8675233125686646,
0.283174067735672,
0.5259225964546204,
... |
javascript/reference/global_objects/string/tolocaleuppercase/index.md | JavaScript - Global Objects - String - toLocaleUpperCase - Syntax - Return value:
A new string representing the calling string converted to upper case, according to any locale-specific case mappings. | [
-0.5153979659080505,
0.13355277478694916,
-0.48715341091156006,
0.2257474958896637,
0.24295958876609802,
-1.5359747409820557,
0.7454636693000793,
0.9819936752319336,
-0.38481593132019043,
0.3901228904724121,
-0.40872564911842346,
1.272530436515808,
-0.045778773725032806,
1.0702488422393799... |
javascript/reference/global_objects/string/tolocaleuppercase/index.md | JavaScript - Global Objects - String - toLocaleUpperCase - Description:
The `toLocaleUpperCase()` method returns the value of the string converted to upper case according to any locale-specific case mappings. `toLocaleUpperCase()` does not affect the value of the string itself. In most cases, this will produce the sam... | [
-0.7589718103408813,
-0.07811356335878372,
-0.603614091873169,
0.17106646299362183,
0.6419718265533447,
-0.8070629835128784,
1.4585177898406982,
0.41214749217033386,
-0.7899591326713562,
-0.06344479322433472,
-0.2127063125371933,
1.4491024017333984,
-0.35493311285972595,
0.5700194835662842... |
javascript/reference/global_objects/string/tolocaleuppercase/index.md | JavaScript - Global Objects - String - toLocaleUpperCase - Examples - Using toLocaleUpperCase():
Example:
"alphabet".toLocaleUpperCase(); // 'ALPHABET'
"Gesäß".toLocaleUpperCase(); // 'GESÄSS'
"i\u0307".toLocaleUpperCase("lt-LT"); // 'I'
const locales = ["lt", "LT", "lt-LT", "lt-u-co-phonebk", "lt-x-lietuva"];
"i\... | [
-0.7474260330200195,
0.4617133140563965,
-0.2895480990409851,
0.23539988696575165,
0.2503112852573395,
-1.0620317459106445,
0.6913692951202393,
0.03753156587481499,
-0.15902741253376007,
-0.2630799114704132,
-0.03196410462260246,
1.1558361053466797,
-0.7380167245864868,
0.02400481514632702... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw:
The `String.raw()` static method is a tag function of template literals. This is similar to the `r` prefix in Python, or the `@` prefix in C# for string literals. It's used to get the raw string form of template literals — that is, substitutions (e.g., `${foo}`) are processe... | [
-2.3360743522644043,
-0.3324792683124542,
-0.2603125274181366,
0.6108687520027161,
0.02796296402812004,
-0.9525890946388245,
1.1049799919128418,
1.3862720727920532,
-0.39270514249801636,
0.9005059003829956,
-0.7877179384231567,
0.27028125524520874,
0.144601508975029,
0.3648596405982971,
... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Syntax:
Example:
String.raw(strings)
String.raw(strings, sub1)
String.raw(strings, sub1, sub2)
String.raw(strings, sub1, sub2, /* …, */ subN)
String.raw`templateString` | [
-1.1790077686309814,
0.36306118965148926,
0.07864174246788025,
-0.07090185582637787,
-0.5767393708229065,
-1.9867421388626099,
0.3529103696346283,
1.0455423593521118,
-0.4560805559158325,
-0.18943195044994354,
-0.976802408695221,
0.13746704161167145,
-0.3705039918422699,
-0.062815696001052... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Syntax - Parameters:
- `strings`: Well-formed template literal array object, like `{ raw: ['foo', 'bar', 'baz'] }`. Should be an object with a `raw` property whose value is an array-like object of strings.
- `sub1`, …, `subN`: Contains substitution values.
- `templateString... | [
-0.5121539235115051,
-0.28692862391471863,
-0.24956296384334564,
-0.13171729445457458,
-0.11777956038713455,
-2.4949982166290283,
0.7553044557571411,
0.7436281442642212,
-0.3871259391307831,
0.33044910430908203,
-0.9034141302108765,
0.28492772579193115,
-0.7771349549293518,
0.3384049832820... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Syntax - Return value:
The raw string form of a given template literal. | [
-0.8932868242263794,
0.26233670115470886,
-0.03381305932998657,
-0.45867791771888733,
-0.5797396898269653,
-1.5079935789108276,
0.9700591564178467,
1.3863109350204468,
-0.23534312844276428,
0.30163612961769104,
-0.9671960473060608,
0.900954008102417,
-0.49702510237693787,
0.817609131336212... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Syntax - Exceptions:
- `TypeError`: Thrown if the first argument doesn't have a `raw` property, or the `raw` property is `undefined` or `null`. | [
-0.8793930411338806,
0.529435932636261,
0.11702966690063477,
0.16888728737831116,
-0.5445383191108704,
-1.7320812940597534,
0.6679131388664246,
1.264025092124939,
-0.19037939608097076,
0.22299692034721375,
-0.7101077437400818,
-0.6504973769187927,
-0.08052889257669449,
-0.3149580955505371,... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Description:
In most cases, `String.raw()` is used with template literals. The first syntax mentioned above is only rarely used, because the JavaScript engine will call this with proper arguments for you, (just like with other tag functions).
`String.raw()` is the only bui... | [
-0.9919872879981995,
0.08291666209697723,
0.1433790624141693,
0.4538024067878723,
0.3421635329723358,
-0.6660600304603577,
0.47704288363456726,
0.6280765533447266,
-0.3921584486961365,
0.6328256726264954,
0.012423069216310978,
0.027347782626748085,
-0.11150585860013962,
0.05794793367385864... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Examples - Using String.raw():
Example:
String.raw`Hi\n${2 + 3}!`;
// 'Hi\\n5!', the character after 'Hi'
// is not a newline character,
// '\' and 'n' are two characters.
String.raw`Hi\u000A!`;
// 'Hi\\u000A!', same here, this time we will get the
// \, u, 0, 0, 0, A, 6 ... | [
-1.3211709260940552,
-0.5623117685317993,
-0.02294725365936756,
0.6077743768692017,
0.18642957508563995,
-1.4508442878723145,
0.46448463201522827,
0.31937381625175476,
-0.3560737371444702,
0.0700509250164032,
-1.0852638483047485,
-0.17009785771369934,
0.014775816351175308,
-0.1093484163284... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Examples - Raw strings containing template literal syntax:
`String.raw` is a function, so it cannot circumvent basic template literal syntax such as backticks as delimiters and `${` for substitutions. If you want to include these characters in the output string, you need to... | [
-0.8863181471824646,
-0.11634102463722229,
0.1384018212556839,
0.6050413250923157,
0.6467100381851196,
-0.972995400428772,
0.7071592807769775,
0.7676506638526917,
-0.3508007526397705,
0.15290437638759613,
-0.061992403119802475,
-0.27437224984169006,
-0.36301085352897644,
0.5857877731323242... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Examples - Using String.raw with RegExp:
Combining a `String.raw` template literal with the `RegExp()` constructor allows you to create regular expressions with dynamic parts (which is not possible with regex literals) without double-escaping (`\\`) regular expression escap... | [
-0.7303917407989502,
0.6306785941123962,
0.023536408320069313,
0.19441036880016327,
0.3394356667995453,
0.25969305634498596,
-0.026777151972055435,
0.5661846995353699,
-0.35115954279899597,
0.08358242362737656,
-0.13094112277030945,
0.08796386420726776,
-1.0236362218856812,
0.2896403968334... |
javascript/reference/global_objects/string/raw/index.md | JavaScript - Global Objects - String - raw - Examples - Building an identity tag:
Many tools give special treatment to literals tagged by a particular name.
Example:
// Some formatters will format this literal's content as HTML
const doc = html`<!doctype html>
<html lang="en-US">
<head>
<title>Hello</tit... | [
-1.0118359327316284,
0.0421944335103035,
0.22049838304519653,
1.0812593698501587,
0.4857523441314697,
-0.4313388466835022,
0.24549923837184906,
0.6126160025596619,
-0.7456724643707275,
-0.05098065361380577,
-0.177174910902977,
-0.09589321166276932,
-0.1341703236103058,
-0.2567882239818573,... |
javascript/reference/global_objects/string/strike/index.md | JavaScript - Global Objects - String - strike:
Deprecated: This feature is no longer recommended.
The `strike()` method of `String` values creates a string that embeds this string in a `strike` element (`<strike>str</strike>`), which causes this string to be displayed as struck-out text.
Note: All HTML wrapper metho... | [
-1.3953803777694702,
-0.3378981351852417,
-0.39696547389030457,
0.1992945820093155,
0.0648525208234787,
-1.9148513078689575,
1.4237877130508423,
0.5024077296257019,
0.2682294547557831,
0.486066997051239,
-0.3791228234767914,
0.40381327271461487,
-0.3902028799057007,
-0.09276434779167175,
... |
javascript/reference/global_objects/string/strike/index.md | JavaScript - Global Objects - String - strike - Syntax:
Example:
strike() | [
-0.46842992305755615,
0.3986474275588989,
-0.8658561110496521,
-0.10258980095386505,
-0.383373498916626,
-1.7187330722808838,
1.0332623720169067,
0.8527377247810364,
0.25137653946876526,
-0.17739218473434448,
-0.6363976001739502,
0.12984152138233185,
-0.8729010224342346,
-0.090867348015308... |
javascript/reference/global_objects/string/strike/index.md | JavaScript - Global Objects - String - strike - Syntax - Parameters:
None. | [
-0.36343914270401,
0.4447387158870697,
-1.0049856901168823,
-0.4313918948173523,
-0.3067353665828705,
-1.0760427713394165,
1.0975971221923828,
1.1286362409591675,
0.23738835752010345,
-0.44285547733306885,
-0.8098585605621338,
-0.6191134452819824,
-0.7655535340309143,
-0.031998664140701294... |
javascript/reference/global_objects/string/strike/index.md | JavaScript - Global Objects - String - strike - Syntax - Return value:
A string beginning with a `<strike>` start tag, then the text `str`, and then a `</strike>` end tag. | [
-1.0792444944381714,
0.2542041540145874,
-0.3176306486129761,
-0.36312440037727356,
0.06697779893875122,
-0.9667584896087646,
0.6961841583251953,
0.8093013167381287,
-0.06381967663764954,
0.08347728848457336,
-0.49583226442337036,
0.23406967520713806,
-0.7930127382278442,
0.498785793781280... |
javascript/reference/global_objects/string/strike/index.md | JavaScript - Global Objects - String - strike - Examples - Using strike():
The code below creates an HTML string and then replaces the document's body with it:
Example:
const contentString = "Hello, world";
document.body.innerHTML = contentString.strike();
This will create the following HTML:
Example:
<strike>He... | [
-0.6657577753067017,
-0.09321561455726624,
0.24325957894325256,
0.7958412766456604,
0.30261728167533875,
-2.14180850982666,
-0.3218507170677185,
-0.38611075282096863,
-0.25608035922050476,
0.22654056549072266,
-0.272090345621109,
0.3167293667793274,
-0.48830053210258484,
-0.616450250148773... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace:
The `replace()` method of `String` values returns a new string with one, some, or all matches of a `pattern` replaced by a `replacement`. The `pattern` can be a string or a `RegExp`, and the `replacement` can be a string or a function called for each match. If `pattern` ... | [
-0.9010553956031799,
-0.4180043637752533,
-0.8781063556671143,
0.1842222362756729,
-0.015546380542218685,
-2.6276252269744873,
0.5429019927978516,
1.0242893695831299,
-0.10534343868494034,
-0.744064211845398,
-0.6170786619186401,
-0.12600412964820862,
-0.422150194644928,
0.6097767353057861... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Syntax:
Example:
replace(pattern, replacement) | [
-0.48183152079582214,
-0.29950758814811707,
-0.8143104910850525,
-0.15678071975708008,
-0.8504855632781982,
-2.7443923950195312,
0.38137274980545044,
1.0992927551269531,
-0.042159270495176315,
-1.1314805746078491,
-0.2668352425098419,
-0.3287733793258667,
-0.6477380990982056,
0.33782300353... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Syntax - Parameters:
- `pattern`: Can be a string or an object with a `Symbol.replace` method — the typical example being a regular expression. Any value that doesn't have the `Symbol.replace` method will be coerced to a string.
- `replacement`: Can be a string or a fun... | [
-0.43102994561195374,
-0.13645857572555542,
-0.8075477480888367,
-0.05964163318276405,
-0.42459937930107117,
-2.729597330093384,
0.7588322758674622,
0.6770260334014893,
0.44895386695861816,
-0.7684788703918457,
-1.008392333984375,
-0.20210404694080353,
-0.6436042189598083,
0.53174507617950... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Syntax - Return value:
A new string, with one, some, or all matches of the pattern replaced by the specified replacement. | [
-0.39750438928604126,
-0.3164066672325134,
-0.7304750084877014,
-0.2622395157814026,
-0.39082780480384827,
-2.0559911727905273,
0.3383278548717499,
0.9059902429580688,
-0.07830705493688583,
-0.4573127031326294,
-0.6726314425468445,
0.06051146984100342,
-0.6442978382110596,
1.26576900482177... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Description:
This method does not mutate the string value it's called on. It returns a new string.
A string pattern will only be replaced once. To perform a global search and replace, use a regular expression with the `g` flag, or use `replaceAll()` instead.
If `patte... | [
-0.9752433896064758,
0.2811913788318634,
-0.5840725898742676,
-0.0017749771941453218,
-0.15095573663711548,
-1.8030740022659302,
0.38064438104629517,
0.5743864178657532,
-0.5565285682678223,
-0.28475135564804077,
-0.5325646996498108,
-0.20421382784843445,
-0.09561783820390701,
0.8221312761... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Description - Specifying a string as the replacement:
The replacement string can include the following special replacement patterns:
- Pattern: `$$`, Inserts: Inserts a `"$"`.
- Pattern: `$&`, Inserts: Inserts the matched substring.
- Pattern: `$``, Inserts: Inserts th... | [
-0.8737354278564453,
-0.3034701347351074,
-0.791170060634613,
0.5172348022460938,
0.09337730705738068,
-1.8764551877975464,
1.0133432149887085,
0.513145923614502,
0.024702735245227814,
0.12140699476003647,
-0.3686246871948242,
-0.4635768532752991,
-1.0882645845413208,
-0.042167965322732925... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Description - Specifying a function as the replacement:
You can specify a function as the second parameter. In this case, the function will be invoked after the match has been performed. The function's result (return value) will be used as the replacement string.
Note:... | [
-0.05842810496687889,
0.10437800735235214,
-0.8264585137367249,
0.6532992720603943,
1.123105764389038,
-1.0843827724456787,
0.07154569774866104,
0.6273930072784424,
-0.4541557729244232,
-0.5077934861183167,
-0.3657705783843994,
-0.5649963021278381,
-0.37778952717781067,
0.6222674250602722,... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Examples - Defining the regular expression in replace():
In the following example, the regular expression is defined in `replace()` and includes the ignore case flag.
Example:
const str = "Twas the night before Xmas...";
const newStr = str.replace(/xmas/i, "Christmas"... | [
-0.10825811326503754,
0.09009888023138046,
-0.6399447917938232,
0.536943256855011,
-0.023869773373007774,
-2.0445122718811035,
0.2998211681842804,
0.7454270124435425,
0.11823532730340958,
-0.03694748878479004,
0.1319083720445633,
-0.6022074222564697,
-0.5228241086006165,
-0.122127287089824... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Examples - Using the global and ignoreCase flags with replace():
Global replace can only be done with a regular expression. In the following example, the regular expression includes the global and ignore case flags which permits `replace()` to replace each occurrence of... | [
-0.6687021255493164,
0.5762221813201904,
-0.0007421070476993918,
0.6039572954177856,
-0.2630639672279358,
-2.686471700668335,
0.09285705536603928,
0.055074431002140045,
-0.3655836284160614,
-0.23256957530975342,
-0.3679288625717163,
-0.8800171613693237,
-0.159524604678154,
0.67965149879455... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Examples - Switching words in a string:
The following script switches the words in the string. For the replacement text, the script uses capturing groups and the `$1` and `$2` replacement patterns.
Example:
const re = /(\w+)\s(\w+)/;
const str = "Maria Cruz";
const ne... | [
-0.8888612985610962,
-0.07612712681293488,
-1.3654485940933228,
0.5336867570877075,
-0.23148463666439056,
-1.537338376045227,
-0.12662695348262787,
1.425843596458435,
-0.0005191679229028523,
-0.36974069476127625,
-0.4615074098110199,
-0.9413043856620789,
-0.06246782839298248,
-0.5098671317... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Examples - Using an inline function that modifies the matched characters:
In this example, all occurrences of capital letters in the string are converted to lower case, and a hyphen is inserted just before the match location. The important thing here is that additional ... | [
-0.7286216020584106,
0.0038710925728082657,
-0.5101223587989807,
0.4574660062789917,
0.9524321556091309,
-1.7813785076141357,
1.1217241287231445,
0.5004902482032776,
-0.40213894844055176,
-0.4321845471858978,
-1.3567209243774414,
0.23427559435367584,
-0.047716885805130005,
-0.0655303522944... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Examples - Replacing a Fahrenheit degree with its Celsius equivalent:
The following example replaces a Fahrenheit degree with its equivalent Celsius degree. The Fahrenheit degree should be a number ending with `"F"`. The function returns the Celsius number ending with `... | [
-1.8964024782180786,
0.12675461173057556,
-0.8534650206565857,
-0.250115305185318,
0.157060906291008,
-2.245288372039795,
0.596208393573761,
-0.15941323339939117,
0.39348140358924866,
-0.089708112180233,
-0.04776821285486221,
0.03343141824007034,
0.33421337604522705,
0.39145272970199585,
... |
javascript/reference/global_objects/string/replace/index.md | JavaScript - Global Objects - String - replace - Examples - Making a generic replacer:
Suppose we want to create a replacer that appends the offset data to every matched string. Because the replacer function already receives the `offset` parameter, it will be trivial if the regex is statically known.
Example:
"abcd"... | [
0.09018070995807648,
0.05651609227061272,
-1.1846855878829956,
0.1621333211660385,
1.0687048435211182,
-1.0860573053359985,
0.23359274864196777,
0.5836169123649597,
-0.2603050470352173,
-0.5393494963645935,
-1.072583794593811,
-0.5972278118133545,
-0.5671281218528748,
0.7287974953651428,
... |
javascript/reference/global_objects/string/anchor/index.md | JavaScript - Global Objects - String - anchor:
Deprecated: This feature is no longer recommended.
The `anchor()` method of `String` values creates a string that embeds this string in an `a` element with a name (`<a name="...">str</a>`).
Note: All HTML wrapper methods are deprecated and only standardized for compatib... | [
-0.8593467473983765,
-0.5557922720909119,
0.13764813542366028,
0.02163519337773323,
-0.5229933857917786,
-1.8899093866348267,
1.41212797164917,
0.15539413690567017,
-0.6290239691734314,
-0.3432517647743225,
-0.023461371660232544,
0.418536901473999,
0.6162405014038086,
-0.2668834328651428,
... |
javascript/reference/global_objects/string/anchor/index.md | JavaScript - Global Objects - String - anchor - Syntax:
Example:
anchor(name) | [
-0.7658647894859314,
-0.25921836495399475,
-0.5970667004585266,
-0.4958238899707794,
-1.2026524543762207,
-2.1664154529571533,
0.8897659182548523,
0.7725749611854553,
-0.6084015369415283,
-0.7334839701652527,
0.08850651979446411,
-0.0332011915743351,
-0.7822706699371338,
-0.078008733689785... |
javascript/reference/global_objects/string/anchor/index.md | JavaScript - Global Objects - String - anchor - Syntax - Parameters:
- `name`: A string representing a `name` value to put into the generated `<a name="...">` start tag. | [
-0.6764342784881592,
-0.4670114517211914,
-0.7740913033485413,
-0.23430708050727844,
-0.6879661083221436,
-1.9391063451766968,
0.8698340058326721,
0.7598193287849426,
-0.19630320370197296,
-0.769615888595581,
-0.448540061712265,
0.19680440425872803,
-0.8388062119483948,
-0.1044440865516662... |
javascript/reference/global_objects/string/anchor/index.md | JavaScript - Global Objects - String - anchor - Syntax - Return value:
A string beginning with an `<a name="name">` start tag (double quotes in `name` are replaced with `"`), then the text `str`, and then an `</a>` end tag. | [
-1.7374526262283325,
0.23158112168312073,
-0.16088645160198212,
-0.5250021815299988,
-0.7226757407188416,
-1.3117029666900635,
1.0125149488449097,
0.49704262614250183,
-0.320818156003952,
-0.2202349752187729,
-0.22283385694026947,
0.45903709530830383,
-0.2838042378425598,
0.122229106724262... |
javascript/reference/global_objects/string/anchor/index.md | JavaScript - Global Objects - String - anchor - Examples - Using anchor():
The code below creates an HTML string and then replaces the document's body with it:
Example:
const contentString = "Hello, world";
document.body.innerHTML = contentString.anchor("hello");
This will create the following HTML:
Example:
<a ... | [
-0.7501794695854187,
-0.0048712086863815784,
0.5152656435966492,
0.40237757563591003,
-0.09702140092849731,
-2.0042872428894043,
-0.43905171751976013,
-0.4334212839603424,
-0.872893750667572,
-0.19303853809833527,
-0.02153884805738926,
0.25189539790153503,
0.021369634196162224,
-0.28405576... |
javascript/reference/global_objects/string/string/index.md | JavaScript - Global Objects - String:
The `String()` constructor creates `String` objects. When called as a function, it returns primitive values of type String. | [
-1.2465996742248535,
-0.007837516255676746,
-0.8917540311813354,
0.6003845930099487,
0.08989996463060379,
-2.0350887775421143,
0.052371054887771606,
0.676531970500946,
-0.26888030767440796,
0.34259113669395447,
-0.8914103507995605,
-0.3641800880432129,
-0.11726616322994232,
-0.263843029737... |
javascript/reference/global_objects/string/string/index.md | JavaScript - Global Objects - String - Syntax:
Example:
new String(thing)
String(thing)
Note: `String()` can be called with or without `new`, but with different effects. See Return value. | [
-0.7439677119255066,
0.2650400698184967,
-0.7682394981384277,
0.42741090059280396,
-0.05147935450077057,
-2.3501439094543457,
-0.2523542046546936,
1.073277235031128,
0.13775677978992462,
-0.2208573818206787,
-0.48228174448013306,
0.6177158951759338,
-0.31751498579978943,
-0.062876030802726... |
javascript/reference/global_objects/string/string/index.md | JavaScript - Global Objects - String - Syntax - Parameters:
- `thing`: Anything to be converted to a string. | [
0.024298319593071938,
0.4904325008392334,
-0.49244600534439087,
0.23752658069133759,
-0.49628689885139465,
-2.308626651763916,
0.1140967383980751,
0.6355380415916443,
0.5720232725143433,
-0.4063665568828583,
-0.9192017316818237,
0.04847206547856331,
-0.16387875378131866,
0.4827643632888794... |
javascript/reference/global_objects/string/string/index.md | JavaScript - Global Objects - String - Syntax - Return value:
When `String()` is called as a function (without `new`), it returns `value` coerced to a string primitive. Specially, Symbol values are converted to `"Symbol(description)"`, where `description` is the description of the Symbol, instead of throwing.
When `S... | [
-0.6302435994148254,
0.46729469299316406,
-0.574815034866333,
0.512762725353241,
-0.1116960346698761,
-2.0498757362365723,
0.453226238489151,
1.0656098127365112,
-0.2511409819126129,
0.8495175242424011,
-0.5680696964263916,
0.26972195506095886,
-0.1318846046924591,
-0.13879163563251495,
... |
javascript/reference/global_objects/string/string/index.md | JavaScript - Global Objects - String - Examples - String constructor and String function:
String function and String constructor produce different results:
Example:
const a = new String("Hello world"); // a === "Hello world" is false
const b = String("Hello world"); // b === "Hello world" is true
a instanceof String... | [
-1.4172993898391724,
-0.4474725127220154,
-0.9423671960830688,
0.5339276194572449,
0.5268717408180237,
-2.2929861545562744,
-1.0620393753051758,
0.45132550597190857,
0.0627913698554039,
0.09032469987869263,
-0.947027325630188,
-0.42219334840774536,
0.2923051416873932,
-0.6017890572547913,
... |
javascript/reference/global_objects/string/string/index.md | JavaScript - Global Objects - String - Examples - Using String() to stringify a symbol:
`String()` is the only case where a symbol can be converted to a string without throwing, because it's very explicit.
Example:
const sym = Symbol("example");
`${sym}`; // TypeError: Cannot convert a Symbol value to a string
"" + ... | [
-0.6008092164993286,
0.3516782224178314,
-0.41697943210601807,
0.12084084749221802,
-0.1479814201593399,
-2.3836655616760254,
-0.29657456278800964,
1.1528393030166626,
0.4054347276687622,
-0.2802967429161072,
-0.0958297997713089,
0.22461828589439392,
0.7843839526176453,
-0.6624236106872559... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.