Upload folder using huggingface_hub
Browse files- data/javascript/test.jsonl +20 -0
- data/javascript/train.jsonl +0 -0
- data/php/test.jsonl +0 -0
- data/php/train.jsonl +0 -0
- data/python/test.jsonl +0 -0
- data/python/train.jsonl +0 -0
data/javascript/test.jsonl
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/supportedLocalesOf/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/intl/collator/supportedlocalesof/index.md\n\n# Original Wiki contributors\nfscholz\nwbamberg\nsideshowbarker\nbattaglr\njameshkramer\narai\neduardoboucas\nMingun\nSheppy\nNorbert\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 74}
|
| 2 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/isRawJSON", "title": "JSON.isRawJSON()", "content": "JSON.isRawJSON()\nLimited availability\nThis feature is not Baseline because it does not work in some of the most widely-used browsers.\nThe JSON.isRawJSON()\nstatic method tests whether a value is an object returned by JSON.rawJSON()\n.\nSyntax\nJSON.isRawJSON(value)\nParameters\nvalue\n-\nThe value to test.\nReturn value\ntrue\nif value\nis created by JSON.rawJSON()\n; otherwise, false\n.\nDescription\n\"Raw JSON\" objects, when serialized to JSON, are treated as if they are already a piece of JSON. Furthermore, because of the way JSON.rawJSON()\nworks, the raw JSON is guaranteed to be syntactically valid JSON. For more information on the shape and behavior of raw JSON objects, see JSON.rawJSON()\n. This method exists to allow other serialization libraries to implement similar behavior to JSON.stringify()\nfor raw JSON objects.\nExamples\nUsing JSON.isRawJSON()\nThe following example demonstrates how to use JSON.isRawJSON()\nto test whether an object was returned by JSON.rawJSON()\n. It implements a custom serializer that serializes data to a YAML-like format.\nfunction mySerializer(value, indent = \"\") {\nif (typeof value !== \"object\" || value === null) {\nreturn JSON.stringify(value);\n}\nif (JSON.isRawJSON(value)) {\nreturn value.rawJSON;\n}\nconst subIndent = `${indent} `;\nif (Array.isArray(value)) {\nreturn `- ${value.map((v) => mySerializer(v, subIndent)).join(`\\n${indent}- `)}`;\n}\nreturn Object.entries(value)\n.map(([key, value]) => {\nconst subValue = mySerializer(value, subIndent);\nif (subValue.includes(\"\\n\")) {\nreturn `${key}:\\n${subIndent}${subValue}`;\n}\nreturn `${key}: ${subValue}`;\n})\n.join(`\\n${indent}`);\n}\nconsole.log(\nmySerializer({\nname: \"Josh\",\nuserId: JSON.rawJSON(\"12345678901234567890\"),\nfriends: [\n{ name: \"Alice\", userId: JSON.rawJSON(\"9876543210987654321\") },\n{ name: \"Bob\", userId: JSON.rawJSON(\"56789012345678901234\") },\n],\n}),\n);\n// name: \"Josh\"\n// userId: 12345678901234567890\n// friends:\n// - name: \"Alice\"\n// userId: 9876543210987654321\n// - name: \"Bob\"\n// userId: 56789012345678901234\nIf in the above example, the userId\nvalues were not created by JSON.rawJSON()\n, but passed as numbers directly, then we will get loss of precision upfront because of JS floating point precision limitations.\nconsole.log(\nmySerializer({\nname: \"Josh\",\nuserId: 12345678901234567890,\nfriends: [\n{ name: \"Alice\", userId: 9876543210987654321 },\n{ name: \"Bob\", userId: 56789012345678901234 },\n],\n}),\n);\n// name: \"Josh\"\n// userId: 12345678901234567000\n// friends:\n// - name: \"Alice\"\n// userId: 9876543210987655000\n// - name: \"Bob\"\n// userId: 56789012345678900000\nSpecifications\n| Specification |\n|---|\n| JSON.parse source text access # sec-json.israwjson |", "code_snippets": ["JSON.isRawJSON(value)\n", "function mySerializer(value, indent = \"\") {\n if (typeof value !== \"object\" || value === null) {\n return JSON.stringify(value);\n }\n if (JSON.isRawJSON(value)) {\n return value.rawJSON;\n }\n const subIndent = `${indent} `;\n if (Array.isArray(value)) {\n return `- ${value.map((v) => mySerializer(v, subIndent)).join(`\\n${indent}- `)}`;\n }\n return Object.entries(value)\n .map(([key, value]) => {\n const subValue = mySerializer(value, subIndent);\n if (subValue.includes(\"\\n\")) {\n return `${key}:\\n${subIndent}${subValue}`;\n }\n return `${key}: ${subValue}`;\n })\n .join(`\\n${indent}`);\n}\n\nconsole.log(\n mySerializer({\n name: \"Josh\",\n userId: JSON.rawJSON(\"12345678901234567890\"),\n friends: [\n { name: \"Alice\", userId: JSON.rawJSON(\"9876543210987654321\") },\n { name: \"Bob\", userId: JSON.rawJSON(\"56789012345678901234\") },\n ],\n }),\n);\n\n// name: \"Josh\"\n// userId: 12345678901234567890\n// friends:\n// - name: \"Alice\"\n// userId: 9876543210987654321\n// - name: \"Bob\"\n// userId: 56789012345678901234\n", "console.log(\n mySerializer({\n name: \"Josh\",\n userId: 12345678901234567890,\n friends: [\n { name: \"Alice\", userId: 9876543210987654321 },\n { name: \"Bob\", userId: 56789012345678901234 },\n ],\n }),\n);\n\n// name: \"Josh\"\n// userId: 12345678901234567000\n// friends:\n// - name: \"Alice\"\n// userId: 9876543210987655000\n// - name: \"Bob\"\n// userId: 56789012345678900000\n"], "language": "JavaScript", "source": "mdn", "token_count": 1035}
|
| 3 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt/asUintN", "title": "BigInt.asUintN()", "content": "BigInt.asUintN()\nBaseline\nWidely available\nThis feature is well established and works across many devices and browser versions. It\u2019s been available across browsers since September 2020.\nThe BigInt.asUintN()\nstatic method truncates a BigInt\nvalue to the given number of least significant bits and returns that value as an unsigned integer.\nTry it\nconst U64_CEIL = 2n ** 64n;\nconsole.log(BigInt.asUintN(64, U64_CEIL - 1n));\n// 18446744073709551615n (2n ** 64n - 1n, the maximum non-wrapping value)\nconsole.log(BigInt.asUintN(64, U64_CEIL));\n// 0n (wraps to zero)\nconsole.log(BigInt.asUintN(64, U64_CEIL + 1n));\n// 1n\nconsole.log(BigInt.asUintN(64, U64_CEIL * 2n));\n// 0n (wraps on multiples)\nconsole.log(BigInt.asUintN(64, U64_CEIL * -42n));\n// 0n (also wraps on negative multiples)\nSyntax\nBigInt.asUintN(bits, bigint)\nParameters\nReturn value\nThe value of bigint\nmodulo 2 ** bits\n, as an unsigned integer.\nExceptions\nRangeError\n-\nThrown if\nbits\nis negative or greater than 253 - 1.\nDescription\nThe BigInt.asUintN\nmethod truncates a BigInt\nvalue to the given number of bits, and interprets the result as an unsigned integer. Unsigned integers have no sign bits and are always non-negative. For example, for BigInt.asUintN(4, 25n)\n, the value 25n\nis truncated to 9n\n:\n25n = 00011001 (base 2) ^==== Use only the four remaining bits ===> 1001 (base 2) = 9n\nNote:\nBigInt\nvalues are always encoded as two's complement in binary.\nUnlike similar language APIs such as Number.prototype.toExponential()\n, asUintN\nis a static property of BigInt\n, so you always use it as BigInt.asUintN()\n, rather than as a method of a BigInt value. Exposing asUintN()\nas a \"standard library function\" allows interop with asm.js.\nExamples\nStaying in 64-bit ranges\nThe BigInt.asUintN()\nmethod can be useful to stay in the range of 64-bit arithmetic.\nconst max = 2n ** 64n - 1n;\nBigInt.asUintN(64, max); // 18446744073709551615n\nBigInt.asUintN(64, max + 1n); // 0n\n// zero because of overflow: the lowest 64 bits are all zeros\nSpecifications\n| Specification |\n|---|\n| ECMAScript\u00ae 2026 Language Specification # sec-bigint.asuintn |", "code_snippets": ["const U64_CEIL = 2n ** 64n;\n\nconsole.log(BigInt.asUintN(64, U64_CEIL - 1n));\n// 18446744073709551615n (2n ** 64n - 1n, the maximum non-wrapping value)\nconsole.log(BigInt.asUintN(64, U64_CEIL));\n// 0n (wraps to zero)\nconsole.log(BigInt.asUintN(64, U64_CEIL + 1n));\n// 1n\nconsole.log(BigInt.asUintN(64, U64_CEIL * 2n));\n// 0n (wraps on multiples)\nconsole.log(BigInt.asUintN(64, U64_CEIL * -42n));\n// 0n (also wraps on negative multiples)\n", "BigInt.asUintN(bits, bigint)\n", "const max = 2n ** 64n - 1n;\n\nBigInt.asUintN(64, max); // 18446744073709551615n\n\nBigInt.asUintN(64, max + 1n); // 0n\n// zero because of overflow: the lowest 64 bits are all zeros\n"], "language": "JavaScript", "source": "mdn", "token_count": 685}
|
| 4 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Already_has_pragma/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/errors/already_has_pragma/index.md\n\n# Original Wiki contributors\nfscholz\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 46}
|
| 5 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString", "title": "Date.prototype.toLocaleTimeString()", "content": "Date.prototype.toLocaleTimeString()\nBaseline\nWidely available\nThis feature is well established and works across many devices and browser versions. It\u2019s been available across browsers since July 2015.\nThe toLocaleTimeString()\nmethod of Date\ninstances returns a string with a language-sensitive representation of the time portion of this date in the local timezone. In implementations with Intl.DateTimeFormat\nAPI support, this method delegates to Intl.DateTimeFormat\n.\nEvery time toLocaleTimeString\nis called, it has to perform a search in a big database of localization strings, which is potentially inefficient. When the method is called many times with the same arguments, it is better to create an Intl.DateTimeFormat\nobject and use its format()\nmethod, because a DateTimeFormat\nobject remembers the arguments passed to it and may decide to cache a slice of the database, so future format\ncalls can search for localization strings within a more constrained context.\nTry it\n// Depending on timezone, your results will vary\nconst event = new Date(\"August 19, 1975 23:15:30 GMT+00:00\");\nconsole.log(event.toLocaleTimeString(\"en-US\"));\n// Expected output: \"1:15:30 AM\"\nconsole.log(event.toLocaleTimeString(\"it-IT\"));\n// Expected output: \"01:15:30\"\nconsole.log(event.toLocaleTimeString(\"ar-EG\"));\n// Expected output: \"\u0661\u0662:\u0661\u0665:\u0663\u0660 \u0635\"\nSyntax\ntoLocaleTimeString()\ntoLocaleTimeString(locales)\ntoLocaleTimeString(locales, options)\nParameters\nThe locales\nand options\nparameters customize the behavior of the function and let applications specify the language whose formatting conventions should be used.\nIn implementations that support the Intl.DateTimeFormat\nAPI, these parameters correspond exactly to the Intl.DateTimeFormat()\nconstructor's parameters. Implementations without Intl.DateTimeFormat\nsupport are asked to ignore both parameters, making the locale used and the form of the string returned entirely implementation-dependent.\nlocales\nOptional-\nA string with a BCP 47 language tag, or an array of such strings. Corresponds to the\nlocales\nparameter of theIntl.DateTimeFormat()\nconstructor.In implementations without\nIntl.DateTimeFormat\nsupport, this parameter is ignored and the host's locale is usually used. options\nOptional-\nAn object adjusting the output format. Corresponds to the\noptions\nparameter of theIntl.DateTimeFormat()\nconstructor. IfdayPeriod\n,hour\n,minute\n,second\n, andfractionalSecondDigits\nare all undefined, thenhour\n,minute\n,second\nwill be set to\"numeric\"\n.In implementations without\nIntl.DateTimeFormat\nsupport, this parameter is ignored.\nSee the Intl.DateTimeFormat()\nconstructor for details on these parameters and how to use them.\nReturn value\nA string representing the time portion of the given date according to language-specific conventions.\nIn implementations with Intl.DateTimeFormat\n, this is equivalent to new Intl.DateTimeFormat(locales, options).format(date)\n, where options\nhas been normalized as described above.\nNote:\nMost of the time, the formatting returned by toLocaleTimeString()\nis consistent. However, the output may vary between implementations, even within the same locale \u2014 output variations are by design and allowed by the specification. It may also not be what you expect. For example, the string may use non-breaking spaces or be surrounded by bidirectional control characters. You should not compare the results of toLocaleTimeString()\nto hardcoded constants.\nExamples\nUsing toLocaleTimeString()\nBasic use of this method without specifying a locale\nreturns a formatted string in the default locale and with default options.\nconst date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));\n// toLocaleTimeString() without arguments depends on the implementation,\n// the default locale, and the default time zone\nconsole.log(date.toLocaleTimeString());\n// \"7:00:00 PM\" if run in en-US locale with time zone America/Los_Angeles\nChecking for support for locales and options parameters\nThe locales\nand options\nparameters may not be supported in all implementations, because support for the internationalization API is optional, and some systems may not have the necessary data. For implementations without internationalization support, toLocaleTimeString()\nalways uses the system's locale, which may not be what you want. Because any implementation that supports the locales\nand options\nparameters must support the Intl\nAPI, you can check the existence of the latter for support:\nfunction toLocaleTimeStringSupportsLocales() {\nreturn (\ntypeof Intl === \"object\" &&\n!!Intl &&\ntypeof Intl.DateTimeFormat === \"function\"\n);\n}\nUsing locales\nThis example shows some of the variations in localized time formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the locales\nargument:\nconst date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n// formats below assume the local time zone of the locale;\n// America/Los_Angeles for the US\n// US English uses 12-hour time with AM/PM\nconsole.log(date.toLocaleTimeString(\"en-US\"));\n// \"7:00:00 PM\"\n// British English uses 24-hour time without AM/PM\nconsole.log(date.toLocaleTimeString(\"en-GB\"));\n// \"03:00:00\"\n// Korean uses 12-hour time with AM/PM\nconsole.log(date.toLocaleTimeString(\"ko-KR\"));\n// \"\uc624\ud6c4 12:00:00\"\n// Arabic in most Arabic speaking countries uses real Arabic digits\nconsole.log(date.toLocaleTimeString(\"ar-EG\"));\n// \"\u0667:\u0660\u0660:\u0660\u0660 \u0645\"\n// when requesting a language that may not be supported, such as\n// Balinese, include a fallback language, in this case Indonesian\nconsole.log(date.toLocaleTimeString([\"ban\", \"id\"]));\n// \"11.00.00\"\nUsing options\nThe results provided by toLocaleTimeString()\ncan be customized using the options\nparameter:\nconst date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n// An application may want to use UTC and make that visible\nconst options = { timeZone: \"UTC\", timeZoneName: \"short\" };\nconsole.log(date.toLocaleTimeString(\"en-US\", options));\n// \"3:00:00 AM GMT\"\n// Sometimes even the US needs 24-hour time\nconsole.log(date.toLocaleTimeString(\"en-US\", { hour12: false }));\n// \"19:00:00\"\n// Show only hours and minutes, use options with the default locale - use an empty array\nconsole.log(\ndate.toLocaleTimeString([], { hour: \"2-digit\", minute: \"2-digit\" }),\n);\n// \"20:01\"\nSpecifications\n| Specification |\n|---|\n| ECMAScript\u00ae 2026 Language Specification # sec-date.prototype.tolocaletimestring |\n| ECMAScript\u00ae 2026 Internationalization API Specification # sup-date.prototype.tolocaletimestring |", "code_snippets": ["// Depending on timezone, your results will vary\nconst event = new Date(\"August 19, 1975 23:15:30 GMT+00:00\");\n\nconsole.log(event.toLocaleTimeString(\"en-US\"));\n// Expected output: \"1:15:30 AM\"\n\nconsole.log(event.toLocaleTimeString(\"it-IT\"));\n// Expected output: \"01:15:30\"\n\nconsole.log(event.toLocaleTimeString(\"ar-EG\"));\n// Expected output: \"\u0661\u0662:\u0661\u0665:\u0663\u0660 \u0635\"\n", "toLocaleTimeString()\ntoLocaleTimeString(locales)\ntoLocaleTimeString(locales, options)\n", "const date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));\n\n// toLocaleTimeString() without arguments depends on the implementation,\n// the default locale, and the default time zone\nconsole.log(date.toLocaleTimeString());\n// \"7:00:00 PM\" if run in en-US locale with time zone America/Los_Angeles\n", "function toLocaleTimeStringSupportsLocales() {\n return (\n typeof Intl === \"object\" &&\n !!Intl &&\n typeof Intl.DateTimeFormat === \"function\"\n );\n}\n", "const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// formats below assume the local time zone of the locale;\n// America/Los_Angeles for the US\n\n// US English uses 12-hour time with AM/PM\nconsole.log(date.toLocaleTimeString(\"en-US\"));\n// \"7:00:00 PM\"\n\n// British English uses 24-hour time without AM/PM\nconsole.log(date.toLocaleTimeString(\"en-GB\"));\n// \"03:00:00\"\n\n// Korean uses 12-hour time with AM/PM\nconsole.log(date.toLocaleTimeString(\"ko-KR\"));\n// \"\uc624\ud6c4 12:00:00\"\n\n// Arabic in most Arabic speaking countries uses real Arabic digits\nconsole.log(date.toLocaleTimeString(\"ar-EG\"));\n// \"\u0667:\u0660\u0660:\u0660\u0660 \u0645\"\n\n// when requesting a language that may not be supported, such as\n// Balinese, include a fallback language, in this case Indonesian\nconsole.log(date.toLocaleTimeString([\"ban\", \"id\"]));\n// \"11.00.00\"\n", "const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));\n\n// An application may want to use UTC and make that visible\nconst options = { timeZone: \"UTC\", timeZoneName: \"short\" };\nconsole.log(date.toLocaleTimeString(\"en-US\", options));\n// \"3:00:00 AM GMT\"\n\n// Sometimes even the US needs 24-hour time\nconsole.log(date.toLocaleTimeString(\"en-US\", { hour12: false }));\n// \"19:00:00\"\n\n// Show only hours and minutes, use options with the default locale - use an empty array\nconsole.log(\n date.toLocaleTimeString([], { hour: \"2-digit\", minute: \"2-digit\" }),\n);\n// \"20:01\"\n"], "language": "JavaScript", "source": "mdn", "token_count": 2195}
|
| 6 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/object/valueof/index.md\n\n# Original Wiki contributors\nmfuji09\nQuelklef\nshaedrich\nfscholz\njpmedley\nwbamberg\nDelapouite\nAbbraxar\nYoumoo\njameshkramer\nUICreation\neduardoboucas\nmrenty\nChrisMondok\nMingun\nSheppy\nethertank\nziyunfei\ngary.court\nSevenspade\nevilpie\nPotappo\nBenoitL\nMgjbot\nYuichirou\nMaian\nMarcoos\nDria\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 108}
|
| 7 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Constructor_cant_be_used_directly/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/errors/constructor_cant_be_used_directly/index.md\n\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 41}
|
| 8 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Called_on_incompatible_type", "title": "TypeError: X.prototype.y called on incompatible type", "content": "TypeError: X.prototype.y called on incompatible type\nThe JavaScript exception \"called on incompatible target (or object)\" occurs when a\nfunction (on a given object), is called with a this\nnot corresponding to\nthe type expected by the function.\nMessage\nTypeError: Method Set.prototype.add called on incompatible receiver undefined (V8-based) TypeError: Bind must be called on a function (V8-based) TypeError: Illegal invocation (V8-based) TypeError: Function.prototype.toString requires that 'this' be a Function (V8-based) TypeError: this is not a Date object. (V8-based) TypeError: this is not a typed array. (V8-based) TypeError: Function.prototype.toString called on incompatible object (Firefox) TypeError: Function.prototype.bind called on incompatible target (Firefox) TypeError: 'addEventListener' called on an object that does not implement interface EventTarget. (Firefox) TypeError: Type error (Safari) TypeError: undefined is not an object (Safari)\nError type\nTypeError\nWhat went wrong?\nWhen this error is thrown, a function (on a given object), is called with a\nthis\nnot corresponding to the type expected by the function.\nThis issue can arise when using the Function.prototype.call()\nor\nFunction.prototype.apply()\nmethods, and providing a this\nargument which does not have the expected type.\nThis issue can also happen when providing a function that is stored as a property of an\nobject as an argument to another function. In this case, the object that stores the\nfunction won't be the this\ntarget of that function when it is called by the\nother function. To work-around this issue, you will either need to wrap the callback function in another function, or use the Function.prototype.bind()\nmethod to\nforce the this\nargument to the expected object.\nExamples\nInvalid cases\nconst mySet = new Set();\n[\"bar\", \"baz\"].forEach(mySet.add);\n// mySet.add is a function, but \"mySet\" is not captured as this.\nfunction myFun() {\nconsole.log(this);\n}\n[\"bar\", \"baz\"].forEach(myFun.bind);\n// myFun.bind is a function, but \"myFun\" is not captured as this.\nValid cases\nconst mySet = new Set();\n[\"bar\", \"baz\"].forEach(mySet.add.bind(mySet));\n// This works due to binding \"mySet\" as this.\nfunction myFun() {\nconsole.log(this);\n}\n[\"bar\", \"baz\"].forEach((x) => myFun.bind(x));\n// This works using the \"bind\" function. It creates a new function forwarding the argument.", "code_snippets": ["const mySet = new Set();\n[\"bar\", \"baz\"].forEach(mySet.add);\n// mySet.add is a function, but \"mySet\" is not captured as this.\n\nfunction myFun() {\n console.log(this);\n}\n[\"bar\", \"baz\"].forEach(myFun.bind);\n// myFun.bind is a function, but \"myFun\" is not captured as this.\n", "const mySet = new Set();\n[\"bar\", \"baz\"].forEach(mySet.add.bind(mySet));\n// This works due to binding \"mySet\" as this.\n\nfunction myFun() {\n console.log(this);\n}\n[\"bar\", \"baz\"].forEach((x) => myFun.bind(x));\n// This works using the \"bind\" function. It creates a new function forwarding the argument.\n"], "language": "JavaScript", "source": "mdn", "token_count": 732}
|
| 9 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode", "title": "Strict mode", "content": "Strict mode\nNote: Sometimes you'll see the default, non-strict mode referred to as sloppy mode. This isn't an official term, but be aware of it, just in case.\nJavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of \"sloppy mode\". Strict mode isn't just a subset: it intentionally has different semantics from normal code. Strict mode code and non-strict mode code can coexist, so scripts can opt into strict mode incrementally.\nStrict mode makes several changes to normal JavaScript semantics:\n- Eliminates some JavaScript silent errors by changing them to throw errors.\n- Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode.\n- Prohibits some syntax likely to be defined in future versions of ECMAScript.\nInvoking strict mode\nStrict mode applies to entire scripts or to individual functions. It doesn't apply to block statements enclosed in {}\nbraces; attempting to apply it to such contexts does nothing. eval\ncode, Function\ncode, event handler attributes, strings passed to setTimeout()\n, and related functions are either function bodies or entire scripts, and invoking strict mode in them works as expected.\nStrict mode for scripts\nTo invoke strict mode for an entire script, put the exact statement \"use strict\";\n(or 'use strict';\n) before any other statements.\n// Whole-script strict mode syntax\n\"use strict\";\nconst v = \"Hi! I'm a strict mode script!\";\nStrict mode for functions\nLikewise, to invoke strict mode for a function, put the exact statement \"use strict\";\n(or 'use strict';\n) in the function's body before any other statements.\nfunction myStrictFunction() {\n// Function-level strict mode syntax\n\"use strict\";\nfunction nested() {\nreturn \"And so am I!\";\n}\nreturn `Hi! I'm a strict mode function! ${nested()}`;\n}\nfunction myNotStrictFunction() {\nreturn \"I'm not strict.\";\n}\nThe \"use strict\"\ndirective can only be applied to the body of functions with simple parameters. Using \"use strict\"\nin functions with rest, default, or destructured parameters is a syntax error.\nfunction sum(a = 1, b = 2) {\n// SyntaxError: \"use strict\" not allowed in function with default parameter\n\"use strict\";\nreturn a + b;\n}\nStrict mode for modules\nThe entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.\nfunction myStrictFunction() {\n// because this is a module, I'm strict by default\n}\nexport default myStrictFunction;\nStrict mode for classes\nAll parts of a class's body are strict mode code, including both class declarations and class expressions.\nclass C1 {\n// All code here is evaluated in strict mode\ntest() {\ndelete Object.prototype;\n}\n}\nnew C1().test(); // TypeError, because test() is in strict mode\nconst C2 = class {\n// All code here is evaluated in strict mode\n};\n// Code here may not be in strict mode\ndelete Object.prototype; // Will not throw error\nChanges in strict mode\nStrict mode changes both syntax and runtime behavior. Changes generally fall into these categories:\n- changes converting mistakes into errors (as syntax errors or at runtime)\n- changes simplifying how variable references are resolved\n- changes simplifying\neval\nandarguments\n- changes making it easier to write \"secure\" JavaScript\n- changes anticipating future ECMAScript evolution.\nConverting mistakes into errors\nStrict mode changes some previously-accepted mistakes into errors. JavaScript was designed to be easy for novice developers, and sometimes it gives operations which should be errors non-error semantics. Sometimes this fixes the immediate problem, but sometimes this creates worse problems in the future. Strict mode treats these mistakes as errors so that they're discovered and promptly fixed.\nAssigning to undeclared variables\nStrict mode makes it impossible to accidentally create global variables. In sloppy mode, mistyping a variable in an assignment creates a new property on the global object and continues to \"work\". Assignments which would accidentally create global variables throw an error in strict mode:\n\"use strict\";\nlet mistypeVariable;\n// Assuming no global variable mistypeVarible exists\n// this line throws a ReferenceError due to the\n// misspelling of \"mistypeVariable\" (lack of an \"a\")\nmistypeVarible = 17;\nFailing to assign to object properties\nStrict mode makes assignments which would otherwise silently fail to throw an exception. There are three ways to fail a property assignment:\n- assignment to a non-writable data property\n- assignment to a getter-only accessor property\n- assignment to a new property on a non-extensible object\nFor example, NaN\nis a non-writable global variable. In sloppy mode, assigning to NaN\ndoes nothing; the developer receives no failure feedback. In strict mode, assigning to NaN\nthrows an exception.\n\"use strict\";\n// Assignment to a non-writable global\nundefined = 5; // TypeError\nInfinity = 5; // TypeError\n// Assignment to a non-writable property\nconst obj1 = {};\nObject.defineProperty(obj1, \"x\", { value: 42, writable: false });\nobj1.x = 9; // TypeError\n// Assignment to a getter-only property\nconst obj2 = {\nget x() {\nreturn 17;\n},\n};\nobj2.x = 5; // TypeError\n// Assignment to a new property on a non-extensible object\nconst fixed = {};\nObject.preventExtensions(fixed);\nfixed.newProp = \"ohai\"; // TypeError\nFailing to delete object properties\nAttempts to delete a non-configurable or otherwise undeletable (e.g., it's intercepted by a proxy's deleteProperty\nhandler which returns false\n) property throw in strict mode (where before the attempt would have no effect):\n\"use strict\";\ndelete Object.prototype; // TypeError\ndelete [].length; // TypeError\nStrict mode also forbids deleting plain names. delete name\nin strict mode is a syntax error:\n\"use strict\";\nvar x;\ndelete x; // syntax error\nIf the name is a configurable global property, prefix it with globalThis\nto delete it.\n\"use strict\";\ndelete globalThis.x;\nDuplicate parameter names\nStrict mode requires that function parameter names be unique. In sloppy mode, the last duplicated argument hides previous identically-named arguments. Those previous arguments remain available through arguments\n, so they're not completely inaccessible. Still, this hiding makes little sense and is probably undesirable (it might hide a typo, for example), so in strict mode, duplicate argument names are a syntax error:\nfunction sum(a, a, c) {\n// syntax error\n\"use strict\";\nreturn a + a + c; // wrong if this code ran\n}\nIt is also a syntax error in non-strict mode to have duplicate parameter names, if the function has a default parameter, rest parameter, or destructured parameter.\nLegacy octal literals\nStrict mode forbids a 0\n-prefixed octal literal. In sloppy mode, a number beginning with a 0\n, such as 0644\n, is interpreted as an octal number (0644 === 420\n), if all digits are smaller than 8. Novice developers sometimes believe a leading-zero prefix has no semantic meaning, so they might use it as an alignment device \u2014 but this changes the number's meaning! A leading-zero syntax for the octal is rarely useful and can be mistakenly used, so strict mode makes it a syntax error:\n\"use strict\";\nconst sum =\n015 + // syntax error\n197 +\n142;\nThe standardized way to denote octal literals is via the 0o\nprefix. For example:\nconst sumWithOctal = 0o10 + 8;\nconsole.log(sumWithOctal); // 16\nOctal escape sequences, such as \"\\45\"\n, which is equal to \"%\"\n, can be used to represent characters by extended-ASCII character code numbers in octal. In strict mode, this is a syntax error. More formally, it's disallowed to have \\\nfollowed by any decimal digit other than 0\n, or \\0\nfollowed by a decimal digit; for example \\9\nand \\07\n.\nSetting properties on primitive values\nStrict mode forbids setting properties on primitive values. Accessing a property on a primitive implicitly creates a wrapper object that's unobservable, so in sloppy mode, setting properties is ignored (no-op). In strict mode, a TypeError\nis thrown.\n\"use strict\";\nfalse.true = \"\"; // TypeError\n(14).sailing = \"home\"; // TypeError\n\"with\".you = \"far away\"; // TypeError\nDuplicate property names\nDuplicate property names used to be considered a SyntaxError\nin strict mode. With the introduction of computed property names, making duplication possible at runtime, this restriction was removed in ES2015.\n\"use strict\";\nconst o = { p: 1, p: 2 }; // syntax error prior to ECMAScript 2015\nNote: Making code that used to error become non-errors is always considered backwards-compatible. This is a good part of the language being strict about throwing errors: it leaves room for future semantic changes.\nSimplifying scope management\nStrict mode simplifies how variable names map to particular variable definitions in the code. Many compiler optimizations rely on the ability to say that variable X is stored in that location: this is critical to fully optimizing JavaScript code. JavaScript sometimes makes this basic mapping of name to variable definition in the code impossible to perform until runtime. Strict mode removes most cases where this happens, so the compiler can better optimize strict mode code.\nRemoval of the with statement\nStrict mode prohibits with\n. The problem with with\nis that any name inside the block might map either to a property of the object passed to it, or to a variable in surrounding (or even global) scope, at runtime; it's impossible to know which beforehand. Strict mode makes with\na syntax error, so there's no chance for a name in a with\nto refer to an unknown location at runtime:\n\"use strict\";\nconst x = 17;\nwith (obj) {\n// Syntax error\n// If this weren't strict mode, would this be const x, or\n// would it instead be obj.x? It's impossible in general\n// to say without running the code, so the name can't be\n// optimized.\nx;\n}\nThe alternative of assigning the object to a short name variable, then accessing the corresponding property on that variable, stands ready to replace with\n.\nNon-leaking eval\nIn strict mode, eval\ndoes not introduce new variables into the surrounding scope. In sloppy mode, eval(\"var x;\")\nintroduces a variable x\ninto the surrounding function or the global scope. This means that, in general, in a function containing a call to eval\n, every name not referring to an argument or local variable must be mapped to a particular definition at runtime (because that eval\nmight have introduced a new variable that would hide the outer variable). In strict mode, eval\ncreates variables only for the code being evaluated, so eval\ncan't affect whether a name refers to an outer variable or some local variable:\nvar x = 17;\nvar evalX = eval(\"'use strict'; var x = 42; x;\");\nconsole.assert(x === 17);\nconsole.assert(evalX === 42);\nWhether the string passed to eval()\nis evaluated in strict mode depends on how eval()\nis invoked (direct eval or indirect eval).\nBlock-scoped function declarations\nThe JavaScript language specification, since its start, had not allowed function declarations nested in block statements. However, it was so intuitive that most browsers implemented it as an extension grammar. Unfortunately, the implementations' semantics diverged, and it became impossible for the language specification to reconcile all implementations. Therefore, block-scoped function declarations are only explicitly specified in strict mode (whereas they were once disallowed in strict mode), while sloppy mode behavior remains divergent among browsers.\nMaking eval and arguments simpler\nStrict mode makes arguments\nand eval\nless bizarrely magical. Both involve a considerable amount of magical behavior in sloppy mode: eval\nto add or remove bindings and to change binding values, and arguments\nsyncing named arguments with its indexed properties. Strict mode makes great strides toward treating eval\nand arguments\nas keywords.\nPreventing binding or assigning eval and arguments\nThe names eval\nand arguments\ncan't be bound or assigned in language syntax. All these attempts to do so are syntax errors:\n\"use strict\";\neval = 17;\narguments++;\n++eval;\nconst obj = { set p(arguments) {} };\nlet eval;\ntry {\n} catch (arguments) {}\nfunction x(eval) {}\nfunction arguments() {}\nconst y = function eval() {};\nconst f = new Function(\"arguments\", \"'use strict'; return 17;\");\nNo syncing between parameters and arguments indices\nStrict mode code doesn't sync indices of the arguments\nobject with each parameter binding. In a sloppy mode function whose first argument is arg\n, setting arg\nalso sets arguments[0]\n, and vice versa (unless no arguments were provided or arguments[0]\nis deleted). arguments\nobjects for strict mode functions store the original arguments when the function was invoked. arguments[i]\ndoes not track the value of the corresponding named argument, nor does a named argument track the value in the corresponding arguments[i]\n.\nfunction f(a) {\n\"use strict\";\na = 42;\nreturn [a, arguments[0]];\n}\nconst pair = f(17);\nconsole.assert(pair[0] === 42);\nconsole.assert(pair[1] === 17);\n\"Securing\" JavaScript\nStrict mode makes it easier to write \"secure\" JavaScript. Some websites now provide ways for users to write JavaScript which will be run by the website on behalf of other users. JavaScript in browsers can access the user's private information, so such JavaScript must be partially transformed before it is run, to censor access to forbidden functionality. JavaScript's flexibility makes it effectively impossible to do this without many runtime checks. Certain language functions are so pervasive that performing runtime checks has a considerable performance cost. A few strict mode tweaks, plus requiring that user-submitted JavaScript be strict mode code and that it be invoked in a certain manner, substantially reduce the need for those runtime checks.\nNo this substitution\nThe value passed as this\nto a function in strict mode is not forced into being an object (a.k.a. \"boxed\"). For a sloppy mode function, this\nis always an object: either the provided object, if called with an object-valued this\n; or the boxed value of this\n, if called with a primitive as this\n; or the global object, if called with undefined\nor null\nas this\n. (Use call\n, apply\n, or bind\nto specify a particular this\n.) Not only is automatic boxing a performance cost, but exposing the global object in browsers is a security hazard because the global object provides access to functionality that \"secure\" JavaScript environments must restrict. Thus for a strict mode function, the specified this\nis not boxed into an object, and if unspecified, this\nis undefined\ninstead of globalThis\n:\n\"use strict\";\nfunction fun() {\nreturn this;\n}\nconsole.assert(fun() === undefined);\nconsole.assert(fun.call(2) === 2);\nconsole.assert(fun.apply(null) === null);\nconsole.assert(fun.call(undefined) === undefined);\nconsole.assert(fun.bind(true)() === true);\nRemoval of stack-walking properties\nIn strict mode it's no longer possible to \"walk\" the JavaScript stack. Many implementations used to implement some extension features that make it possible to detect the upstream caller of a function. When a function fun\nis in the middle of being called, fun.caller\nis the function that most recently called fun\n, and fun.arguments\nis the arguments\nfor that invocation of fun\n. Both extensions are problematic for \"secure\" JavaScript because they allow \"secured\" code to access \"privileged\" functions and their (potentially unsecured) arguments. If fun\nis in strict mode, both fun.caller\nand fun.arguments\nare non-deletable properties which throw when set or retrieved:\nfunction restricted() {\n\"use strict\";\nrestricted.caller; // throws a TypeError\nrestricted.arguments; // throws a TypeError\n}\nfunction privilegedInvoker() {\nreturn restricted();\n}\nprivilegedInvoker();\nSimilarly, arguments.callee\nis no longer supported. In sloppy mode, arguments.callee\nrefers to the enclosing function. This use case is weak: name the enclosing function! Moreover, arguments.callee\nsubstantially hinders optimizations like inlining functions, because it must be made possible to provide a reference to the un-inlined function if arguments.callee\nis accessed. arguments.callee\nfor strict mode functions is a non-deletable property which throws an error when set or retrieved:\n\"use strict\";\nfunction f() {\nreturn arguments.callee;\n}\nf(); // throws a TypeError\nFuture-proofing JavaScript\nExtra reserved words\nReserved words are identifiers that can't be used as variable names. Strict mode reserves some more names than sloppy mode, some of which are already used in the language, and some of which are reserved for the future to make future syntax extensions easier to implement.\nTransitioning to strict mode\nStrict mode has been designed so that the transition to it can be made gradually. It is possible to change each file individually and even to transition code to strict mode down to the function granularity.\nYou can migrate a codebase to strict mode by first adding \"use strict\"\nto a piece of source code, and then fixing all execution errors, while watching out for semantic differences.\nSyntax errors\nWhen adding 'use strict';\n, the following cases will throw a SyntaxError\nbefore the script is executing:\n- Octal syntax\nconst n = 023;\nwith\nstatement- Using\ndelete\non a variable namedelete myVariable\n; - Using\neval\norarguments\nas variable or function argument name - Using one of the newly reserved keywords (in prevision for future language features):\nimplements\n,interface\n,let\n,package\n,private\n,protected\n,public\n,static\n, andyield\n- Declaring two function parameters with the same name\nfunction f(a, b, b) {}\n- Declaring the same property name twice in an object literal\n{a: 1, b: 3, a: 7}\n. This constraint was later removed (bug 1041128).\nThese errors are good, because they reveal plain errors or bad practices. They occur before the code is running, so they are easily discoverable as long as the code gets parsed by the runtime.\nNew runtime errors\nJavaScript used to silently fail in contexts where what was done should be an error. Strict mode throws in such cases. If your code base contains such cases, testing will be necessary to be sure nothing is broken. You can screen for such errors at the function granularity level.\n- Assigning to an undeclared variable throws a\nReferenceError\n. This used to set a property on the global object, which is rarely the expected effect. If you really want to set a value to the global object, explicitly assign it as a property onglobalThis\n. - Failing to assign to an object's property (e.g., it's read-only) throws a\nTypeError\n. In sloppy mode, this would silently fail. - Deleting a non-deletable property throws a\nTypeError\n. In sloppy mode, this would silently fail. - Accessing\narguments.callee\n,strictFunction.caller\n, orstrictFunction.arguments\nthrows aTypeError\nif the function is in strict mode. If you are usingarguments.callee\nto call the function recursively, you can use a named function expression instead.\nSemantic differences\nThese differences are very subtle differences. It's possible that a test suite doesn't catch this kind of subtle difference. Careful review of your code base will probably be necessary to be sure these differences don't affect the semantics of your code. Fortunately, this careful review can be done gradually down the function granularity.\nthis\n-\nIn sloppy mode, function calls like\nf()\nwould pass the global object as thethis\nvalue. In strict mode, it is nowundefined\n. When a function was called withcall\norapply\n, if the value was a primitive value, this one was boxed into an object (or the global object forundefined\nandnull\n). In strict mode, the value is passed directly without conversion or replacement. arguments\n-\nIn sloppy mode, modifying a value in the\narguments\nobject modifies the corresponding named argument. This made optimizations complicated for JavaScript engine and made code harder to read/understand. In strict mode, thearguments\nobject is created and initialized with the same values than the named arguments, but changes to either thearguments\nobject or the named arguments aren't reflected in one another. eval\n-\nIn strict mode code,\neval\ndoesn't create a new variable in the scope from which it was called. Also, of course, in strict mode, the string is evaluated with strict mode rules. Thorough testing will need to be performed to make sure nothing breaks. Not using eval if you don't really need it may be another pragmatic solution. - Block-scoped function declarations\n-\nIn sloppy mode, a function declaration inside a block may be visible outside the block and even callable. In strict mode, a function declaration inside a block is only visible inside the block.\nSpecifications\n| Specification |\n|---|\n| ECMAScript\u00ae 2026 Language Specification |", "code_snippets": ["// Whole-script strict mode syntax\n\"use strict\";\nconst v = \"Hi! I'm a strict mode script!\";\n", "function myStrictFunction() {\n // Function-level strict mode syntax\n \"use strict\";\n function nested() {\n return \"And so am I!\";\n }\n return `Hi! I'm a strict mode function! ${nested()}`;\n}\nfunction myNotStrictFunction() {\n return \"I'm not strict.\";\n}\n", "function sum(a = 1, b = 2) {\n // SyntaxError: \"use strict\" not allowed in function with default parameter\n \"use strict\";\n return a + b;\n}\n", "function myStrictFunction() {\n // because this is a module, I'm strict by default\n}\nexport default myStrictFunction;\n", "class C1 {\n // All code here is evaluated in strict mode\n test() {\n delete Object.prototype;\n }\n}\nnew C1().test(); // TypeError, because test() is in strict mode\n\nconst C2 = class {\n // All code here is evaluated in strict mode\n};\n\n// Code here may not be in strict mode\ndelete Object.prototype; // Will not throw error\n", "\"use strict\";\nlet mistypeVariable;\n\n// Assuming no global variable mistypeVarible exists\n// this line throws a ReferenceError due to the\n// misspelling of \"mistypeVariable\" (lack of an \"a\")\nmistypeVarible = 17;\n", "\"use strict\";\n\n// Assignment to a non-writable global\nundefined = 5; // TypeError\nInfinity = 5; // TypeError\n\n// Assignment to a non-writable property\nconst obj1 = {};\nObject.defineProperty(obj1, \"x\", { value: 42, writable: false });\nobj1.x = 9; // TypeError\n\n// Assignment to a getter-only property\nconst obj2 = {\n get x() {\n return 17;\n },\n};\nobj2.x = 5; // TypeError\n\n// Assignment to a new property on a non-extensible object\nconst fixed = {};\nObject.preventExtensions(fixed);\nfixed.newProp = \"ohai\"; // TypeError\n", "\"use strict\";\ndelete Object.prototype; // TypeError\ndelete [].length; // TypeError\n", "\"use strict\";\n\nvar x;\ndelete x; // syntax error\n", "\"use strict\";\n\ndelete globalThis.x;\n", "function sum(a, a, c) {\n // syntax error\n \"use strict\";\n return a + a + c; // wrong if this code ran\n}\n", "\"use strict\";\nconst sum =\n 015 + // syntax error\n 197 +\n 142;\n", "const sumWithOctal = 0o10 + 8;\nconsole.log(sumWithOctal); // 16\n", "\"use strict\";\n\nfalse.true = \"\"; // TypeError\n(14).sailing = \"home\"; // TypeError\n\"with\".you = \"far away\"; // TypeError\n", "\"use strict\";\nconst o = { p: 1, p: 2 }; // syntax error prior to ECMAScript 2015\n", "\"use strict\";\nconst x = 17;\nwith (obj) {\n // Syntax error\n // If this weren't strict mode, would this be const x, or\n // would it instead be obj.x? It's impossible in general\n // to say without running the code, so the name can't be\n // optimized.\n x;\n}\n", "var x = 17;\nvar evalX = eval(\"'use strict'; var x = 42; x;\");\nconsole.assert(x === 17);\nconsole.assert(evalX === 42);\n", "\"use strict\";\neval = 17;\narguments++;\n++eval;\nconst obj = { set p(arguments) {} };\nlet eval;\ntry {\n} catch (arguments) {}\nfunction x(eval) {}\nfunction arguments() {}\nconst y = function eval() {};\nconst f = new Function(\"arguments\", \"'use strict'; return 17;\");\n", "function f(a) {\n \"use strict\";\n a = 42;\n return [a, arguments[0]];\n}\nconst pair = f(17);\nconsole.assert(pair[0] === 42);\nconsole.assert(pair[1] === 17);\n", "\"use strict\";\nfunction fun() {\n return this;\n}\nconsole.assert(fun() === undefined);\nconsole.assert(fun.call(2) === 2);\nconsole.assert(fun.apply(null) === null);\nconsole.assert(fun.call(undefined) === undefined);\nconsole.assert(fun.bind(true)() === true);\n", "function restricted() {\n \"use strict\";\n restricted.caller; // throws a TypeError\n restricted.arguments; // throws a TypeError\n}\nfunction privilegedInvoker() {\n return restricted();\n}\nprivilegedInvoker();\n", "\"use strict\";\nfunction f() {\n return arguments.callee;\n}\nf(); // throws a TypeError\n"], "language": "JavaScript", "source": "mdn", "token_count": 6101}
|
| 10 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DurationFormat/resolvedOptions", "title": "Intl.DurationFormat.prototype.resolvedOptions()", "content": "Intl.DurationFormat.prototype.resolvedOptions()\nBaseline\n2025\nNewly available\nSince March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.\nThe resolvedOptions()\nmethod of Intl.DurationFormat\ninstances returns a new object with properties reflecting the options computed during initialization of this DurationFormat\nobject.\nSyntax\nresolvedOptions()\nParameters\nNone.\nReturn value\nA new object with properties reflecting the options computed during the initialization of this DurationFormat\nobject. The object has the following properties, in the order they are listed:\nlocale\n-\nThe BCP 47 language tag for the locale actually used, determined by the locale negotiation process. Only the\nnu\nUnicode extension key, if requested, may be included in the output. numberingSystem\n-\nThe value provided for this property in the\noptions\nargument, or using the Unicode extension key\"nu\"\n, with default filled in as needed. It is a supported numbering system for this locale. The default is locale dependent. style\n-\nThe value provided for this property in the\noptions\nargument, with default filled in as needed. It is either\"long\"\n,\"short\"\n,\"narrow\"\n, or\"digital\"\n. The default is\"short\"\n. years\n,yearsDisplay\n,months\n,monthsDisplay\n,weeks\n,weeksDisplay\n,days\n,daysDisplay\n,hours\n,hoursDisplay\n,minutes\n,minutesDisplay\n,seconds\n,secondsDisplay\n,milliseconds\n,millisecondsDisplay\n,nanoseconds\n,nanosecondsDisplay\n-\nThe values provided for these properties in the\noptions\nargument, with defaults filled in as needed. For the valid values and defaults for each, see theoptions\nargument of the constructor. fractionalDigits\nOptional-\nThe value provided for this property in the\noptions\nargument. It is only present if specified inoptions\n. It is an integer from 0 to 9, inclusive.\nExamples\nUsing the resolvedOptions method\nconst duration = new Intl.DurationFormat(\"en\");\nconst usedOptions = duration.resolvedOptions();\nusedOptions.locale; // \"en\"\nusedOptions.numberingSystem; // \"latn\"\nusedOptions.years; // \"long\"\nusedOptions.yearsDisplay; // \"auto\"\nusedOptions.style; // \"long\"\nSpecifications\n| Specification |\n|---|\n| Intl.DurationFormat # sec-Intl.DurationFormat.prototype.resolvedOptions |", "code_snippets": ["resolvedOptions()\n", "const duration = new Intl.DurationFormat(\"en\");\nconst usedOptions = duration.resolvedOptions();\n\nusedOptions.locale; // \"en\"\nusedOptions.numberingSystem; // \"latn\"\nusedOptions.years; // \"long\"\nusedOptions.yearsDisplay; // \"auto\"\nusedOptions.style; // \"long\"\n"], "language": "JavaScript", "source": "mdn", "token_count": 634}
|
| 11 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Key_not_weakly_held", "title": "TypeError: WeakSet key/WeakMap value 'x' must be an object or an unregistered symbol", "content": "TypeError: WeakSet key/WeakMap value 'x' must be an object or an unregistered symbol\nThe JavaScript exception \"WeakSet key (or WeakMap value) 'x' must be an object or an unregistered symbol\" occurs when a value of invalid type is used as a key in a WeakSet\nor as a value in a WeakMap\n.\nMessage\nTypeError: Invalid value used as weak map key (V8-based) TypeError: WeakMap key 1 must be an object or an unregistered symbol (Firefox) TypeError: WeakMap keys must be objects or non-registered symbols (Safari) TypeError: Invalid value used in weak set (V8-based) TypeError: WeakSet value 1 must be an object or an unregistered symbol (Firefox) TypeError: WeakSet values must be objects or non-registered symbols (Safari)\nError type\nTypeError\nWhat went wrong?\nWeakSet\nand WeakMap\nrequire the keys to be garbage collectable. Only objects and non-registered symbols (that is, symbols not returned by Symbol.for()\n) are valid. For more information, see Memory management. If you want to add keys that are strings, numbers, or other primitive values, you should store them in a regular Set\nor Map\ninstead.\nExamples\nInvalid cases\njs\nnew WeakSet().add(1); // TypeError\nnew WeakMap().set(1, {}); // TypeError\nnew WeakSet([1]); // TypeError\nnew WeakMap([[1, {}]]); // TypeError\nValid cases\njs\nnew WeakSet().add({}); // OK\nnew WeakMap().set({}, 1); // OK\nnew Set([1]); // OK\nnew Map([[1, {}]]); // OK", "code_snippets": ["new WeakSet().add(1); // TypeError\nnew WeakMap().set(1, {}); // TypeError\nnew WeakSet([1]); // TypeError\nnew WeakMap([[1, {}]]); // TypeError\n", "new WeakSet().add({}); // OK\nnew WeakMap().set({}, 1); // OK\n\nnew Set([1]); // OK\nnew Map([[1, {}]]); // OK\n"], "language": "JavaScript", "source": "mdn", "token_count": 408}
|
| 12 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/supportedLocalesOf", "title": "Intl.Collator.supportedLocalesOf()", "content": "Intl.Collator.supportedLocalesOf()\nBaseline\nWidely available\nThis feature is well established and works across many devices and browser versions. It\u2019s been available across browsers since September 2017.\nThe Intl.Collator.supportedLocalesOf()\nstatic method returns an array containing those of the provided locales that are supported in collation without having to fall back to the runtime's default locale.\nTry it\nconst locales = [\"ban\", \"id-u-co-pinyin\", \"de-ID\"];\nconst options = { localeMatcher: \"lookup\" };\nconsole.log(Intl.Collator.supportedLocalesOf(locales, options));\n// Expected output: Array [\"id-u-co-pinyin\", \"de-ID\"]\n// (Note: the exact output may be browser-dependent)\nSyntax\nIntl.Collator.supportedLocalesOf(locales)\nIntl.Collator.supportedLocalesOf(locales, options)\nParameters\nlocales\n-\nA string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the\nlocales\nargument, see the parameter description on theIntl\nmain page. options\nOptional-\nAn object that may have the following property:\nlocaleMatcher\n-\nThe locale matching algorithm to use. Possible values are\n\"lookup\"\nand\"best fit\"\n; the default is\"best fit\"\n. For information about this option, see the Intl page.\nReturn value\nAn array of strings representing a subset of the given locale tags that are supported in collation without having to fall back to the runtime's default locale.\nExamples\nUsing supportedLocalesOf()\nAssuming a runtime that supports Indonesian and German but not Balinese in collation, supportedLocalesOf\nreturns the Indonesian and German language tags unchanged, even though pinyin\ncollation is not used with Indonesian, and a specialized German for Indonesia is unlikely to be supported. Note the specification of the \"lookup\"\nalgorithm here \u2014 a \"best fit\"\nmatcher might decide that Indonesian is an adequate match for Balinese since most Balinese speakers also understand Indonesian, and therefore return the Balinese language tag as well.\nconst locales = [\"ban\", \"id-u-co-pinyin\", \"de-ID\"];\nconst options = { localeMatcher: \"lookup\" };\nconsole.log(Intl.Collator.supportedLocalesOf(locales, options));\n// [\"id-u-co-pinyin\", \"de-ID\"]\nSpecifications\n| Specification |\n|---|\n| ECMAScript\u00ae 2026 Internationalization API Specification # sec-intl.collator.supportedlocalesof |", "code_snippets": ["const locales = [\"ban\", \"id-u-co-pinyin\", \"de-ID\"];\nconst options = { localeMatcher: \"lookup\" };\n\nconsole.log(Intl.Collator.supportedLocalesOf(locales, options));\n// Expected output: Array [\"id-u-co-pinyin\", \"de-ID\"]\n// (Note: the exact output may be browser-dependent)\n", "Intl.Collator.supportedLocalesOf(locales)\nIntl.Collator.supportedLocalesOf(locales, options)\n", "const locales = [\"ban\", \"id-u-co-pinyin\", \"de-ID\"];\nconst options = { localeMatcher: \"lookup\" };\nconsole.log(Intl.Collator.supportedLocalesOf(locales, options));\n// [\"id-u-co-pinyin\", \"de-ID\"]\n"], "language": "JavaScript", "source": "mdn", "token_count": 718}
|
| 13 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/No_properties", "title": "TypeError: null/undefined has no properties", "content": "TypeError: null/undefined has no properties\nThe JavaScript exception \"null (or undefined) has no properties\" occurs when you\nattempt to access properties of null\nand undefined\n. They\ndon't have any.\nMessage\nTypeError: Cannot read properties of undefined (reading 'x') (V8-based) TypeError: Cannot destructure 'x' as it is undefined. (V8-based) TypeError: Cannot destructure property 'x' of 'y' as it is undefined. (V8-based) TypeError: null has no properties (Firefox) TypeError: undefined has no properties (Firefox) TypeError: undefined is not an object (evaluating 'undefined.x') (Safari) TypeError: Right side of assignment cannot be destructured (Safari)\nError type\nWhat went wrong?\nBoth null\nand undefined\nhave no properties you could access. Therefore, you cannot use property accessors on them, or destructure them.\nExamples\nnull and undefined have no properties\njs\nnull.foo;\n// TypeError: null has no properties\nundefined.bar;\n// TypeError: undefined has no properties", "code_snippets": ["null.foo;\n// TypeError: null has no properties\n\nundefined.bar;\n// TypeError: undefined has no properties\n"], "language": "JavaScript", "source": "mdn", "token_count": 270}
|
| 14 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatRangeToParts/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/intl/numberformat/formatrangetoparts/index.md\n\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 43}
|
| 15 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Now/plainDateISO/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/temporal/now/plaindateiso/index.md\n\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 41}
|
| 16 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Now/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/temporal/now/index.md\n\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 37}
|
| 17 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/getCanonicalLocales", "title": "Intl.getCanonicalLocales()", "content": "Intl.getCanonicalLocales()\nBaseline\nWidely available\nThis feature is well established and works across many devices and browser versions. It\u2019s been available across browsers since October 2017.\nThe Intl.getCanonicalLocales()\nstatic method returns an array\ncontaining the canonical locale names. Duplicates will be omitted and elements will be\nvalidated as structurally valid language tags.\nTry it\nconsole.log(Intl.getCanonicalLocales(\"EN-US\"));\n// Expected output: Array [\"en-US\"]\nconsole.log(Intl.getCanonicalLocales([\"EN-US\", \"Fr\"]));\n// Expected output: Array [\"en-US\", \"fr\"]\ntry {\nIntl.getCanonicalLocales(\"EN_US\");\n} catch (err) {\nconsole.log(err.toString());\n// Expected output: RangeError: invalid language tag: \"EN_US\"\n}\nSyntax\njs\nIntl.getCanonicalLocales(locales)\nParameters\nReturn value\nAn array containing the canonical locale names.\nExamples\nUsing getCanonicalLocales\njs\nIntl.getCanonicalLocales(\"EN-US\"); // [\"en-US\"]\nIntl.getCanonicalLocales([\"EN-US\", \"Fr\"]); // [\"en-US\", \"fr\"]\nIntl.getCanonicalLocales(\"EN_US\");\n// RangeError: invalid language tag: \"EN_US\"\nSpecifications\n| Specification |\n|---|\n| ECMAScript\u00ae 2026 Internationalization API Specification # sec-intl.getcanonicallocales |", "code_snippets": ["console.log(Intl.getCanonicalLocales(\"EN-US\"));\n// Expected output: Array [\"en-US\"]\n\nconsole.log(Intl.getCanonicalLocales([\"EN-US\", \"Fr\"]));\n// Expected output: Array [\"en-US\", \"fr\"]\n\ntry {\n Intl.getCanonicalLocales(\"EN_US\");\n} catch (err) {\n console.log(err.toString());\n // Expected output: RangeError: invalid language tag: \"EN_US\"\n}\n", "Intl.getCanonicalLocales(locales)\n", "Intl.getCanonicalLocales(\"EN-US\"); // [\"en-US\"]\nIntl.getCanonicalLocales([\"EN-US\", \"Fr\"]); // [\"en-US\", \"fr\"]\n\nIntl.getCanonicalLocales(\"EN_US\");\n// RangeError: invalid language tag: \"EN_US\"\n"], "language": "JavaScript", "source": "mdn", "token_count": 441}
|
| 18 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NaN/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/number/nan/index.md\n\n# Original Wiki contributors\nmfuji09\nchrisdavidmills\nfscholz\nwbamberg\njameshkramer\nMingun\nSheppy\nslippyd\ndbruant\nevilpie\nMgjbot\nSevenspade\nDiablownik\nMaian\nNickolay\nDria\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 80}
|
| 19 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat", "title": "Intl.RelativeTimeFormat", "content": "Intl.RelativeTimeFormat\nBaseline\nWidely available\nThis feature is well established and works across many devices and browser versions. It\u2019s been available across browsers since September 2020.\nThe Intl.RelativeTimeFormat\nobject enables language-sensitive relative time formatting.\nTry it\nconst rtf1 = new Intl.RelativeTimeFormat(\"en\", { style: \"short\" });\nconsole.log(rtf1.format(3, \"quarter\"));\n// Expected output: \"in 3 qtrs.\"\nconsole.log(rtf1.format(-1, \"day\"));\n// Expected output: \"1 day ago\"\nconst rtf2 = new Intl.RelativeTimeFormat(\"es\", { numeric: \"auto\" });\nconsole.log(rtf2.format(2, \"day\"));\n// Expected output: \"pasado ma\u00f1ana\"\nConstructor\nIntl.RelativeTimeFormat()\n-\nCreates a new\nIntl.RelativeTimeFormat\nobject.\nStatic methods\nIntl.RelativeTimeFormat.supportedLocalesOf()\n-\nReturns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.\nInstance properties\nThese properties are defined on Intl.RelativeTimeFormat.prototype\nand shared by all Intl.RelativeTimeFormat\ninstances.\nIntl.RelativeTimeFormat.prototype.constructor\n-\nThe constructor function that created the instance object. For\nIntl.RelativeTimeFormat\ninstances, the initial value is theIntl.RelativeTimeFormat\nconstructor. Intl.RelativeTimeFormat.prototype[Symbol.toStringTag]\n-\nThe initial value of the\n[Symbol.toStringTag]\nproperty is the string\"Intl.RelativeTimeFormat\"\n. This property is used inObject.prototype.toString()\n.\nInstance methods\nIntl.RelativeTimeFormat.prototype.format()\n-\nFormats a\nvalue\nand aunit\naccording to the locale and formatting options of the givenIntl.RelativeTimeFormat\nobject. Intl.RelativeTimeFormat.prototype.formatToParts()\n-\nReturns an\nArray\nof objects representing the relative time format in parts that can be used for custom locale-aware formatting. Intl.RelativeTimeFormat.prototype.resolvedOptions()\n-\nReturns a new object with properties reflecting the locale and formatting options computed during initialization of the object.\nExamples\nBasic format usage\nThe following example shows how to use a relative time formatter for the English language.\n// Create a relative time formatter in your locale\n// with default values explicitly passed in.\nconst rtf = new Intl.RelativeTimeFormat(\"en\", {\nlocaleMatcher: \"best fit\", // other values: \"lookup\"\nnumeric: \"always\", // other values: \"auto\"\nstyle: \"long\", // other values: \"short\" or \"narrow\"\n});\n// Format relative time using negative value (-1).\nrtf.format(-1, \"day\"); // \"1 day ago\"\n// Format relative time using positive value (1).\nrtf.format(1, \"day\"); // \"in 1 day\"\nUsing formatToParts\nThe following example shows how to create a relative time formatter returning formatted parts.\nconst rtf = new Intl.RelativeTimeFormat(\"en\", { numeric: \"auto\" });\n// Format relative time using the day unit.\nrtf.formatToParts(-1, \"day\");\n// [{ type: \"literal\", value: \"yesterday\"}]\nrtf.formatToParts(100, \"day\");\n// [\n// { type: \"literal\", value: \"in \" },\n// { type: \"integer\", value: \"100\", unit: \"day\" },\n// { type: \"literal\", value: \" days\" }\n// ]\nSpecifications\n| Specification |\n|---|\n| ECMAScript\u00ae 2026 Internationalization API Specification # relativetimeformat-objects |\nBrowser compatibility\nSee also\n- Polyfill of\nIntl.RelativeTimeFormat\nin FormatJS Intl\nIntl.RelativeTimeFormat\non v8.dev (2018)", "code_snippets": ["const rtf1 = new Intl.RelativeTimeFormat(\"en\", { style: \"short\" });\n\nconsole.log(rtf1.format(3, \"quarter\"));\n// Expected output: \"in 3 qtrs.\"\n\nconsole.log(rtf1.format(-1, \"day\"));\n// Expected output: \"1 day ago\"\n\nconst rtf2 = new Intl.RelativeTimeFormat(\"es\", { numeric: \"auto\" });\n\nconsole.log(rtf2.format(2, \"day\"));\n// Expected output: \"pasado ma\u00f1ana\"\n", "// Create a relative time formatter in your locale\n// with default values explicitly passed in.\nconst rtf = new Intl.RelativeTimeFormat(\"en\", {\n localeMatcher: \"best fit\", // other values: \"lookup\"\n numeric: \"always\", // other values: \"auto\"\n style: \"long\", // other values: \"short\" or \"narrow\"\n});\n\n// Format relative time using negative value (-1).\nrtf.format(-1, \"day\"); // \"1 day ago\"\n\n// Format relative time using positive value (1).\nrtf.format(1, \"day\"); // \"in 1 day\"\n", "const rtf = new Intl.RelativeTimeFormat(\"en\", { numeric: \"auto\" });\n\n// Format relative time using the day unit.\nrtf.formatToParts(-1, \"day\");\n// [{ type: \"literal\", value: \"yesterday\"}]\n\nrtf.formatToParts(100, \"day\");\n// [\n// { type: \"literal\", value: \"in \" },\n// { type: \"integer\", value: \"100\", unit: \"day\" },\n// { type: \"literal\", value: \" days\" }\n// ]\n"], "language": "JavaScript", "source": "mdn", "token_count": 1132}
|
| 20 |
+
{"url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/resolvedOptions/contributors.txt", "title": null, "content": "# Contributors by commit history\nhttps://github.com/mdn/content/commits/main/files/en-us/web/javascript/reference/global_objects/intl/collator/resolvedoptions/index.md\n\n# Original Wiki contributors\nmfuji09\nfscholz\nsideshowbarker\nbattaglr\nwbamberg\nmaboa\njameshkramer\narai\neduardoboucas\nMingun\nSheppy\nNorbert\n", "code_snippets": [], "language": "JavaScript", "source": "mdn", "token_count": 76}
|
data/javascript/train.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/php/test.jsonl
ADDED
|
File without changes
|
data/php/train.jsonl
ADDED
|
File without changes
|
data/python/test.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/python/train.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|