file
stringlengths
16
94
text
stringlengths
32
24.4k
vector
list
javascript/reference/errors/regex_backslash_at_end_of_pattern/index.md
JavaScript - Errors - Regex backslash at end of pattern: The JavaScript exception "\ at end of pattern" occurs when a regular expression pattern ends with an unescaped backslash (`\`). In a regex literal, the backslash would cause the closing slash `/` to be a literal character, so this can only appear when using the ...
[ -0.9567552804946899, 0.05022517591714859, -0.6625047326087952, -0.30541539192199707, -0.2443813532590866, -0.5706855654716492, 0.07140506058931351, 1.1101192235946655, -0.5378239750862122, -0.30145514011383057, -0.4841708838939667, -0.13011281192302704, -0.15517975389957428, -0.22295470535...
javascript/reference/errors/regex_backslash_at_end_of_pattern/index.md
JavaScript - Errors - Regex backslash at end of pattern - Message: Example: SyntaxError: Invalid regular expression: /\/: \ at end of pattern (V8-based) SyntaxError: \ at end of pattern (Firefox) SyntaxError: Invalid regular expression: \ at end of pattern (Safari)
[ -0.40484604239463806, 0.20748315751552582, -0.9617425203323364, -0.622607946395874, -0.5396449565887451, -1.080196738243103, 0.322102427482605, 1.3140416145324707, -0.2772774398326874, -0.2971741855144501, -0.19960133731365204, -0.15977081656455994, 0.42201825976371765, -0.2923175096511841...
javascript/reference/errors/regex_backslash_at_end_of_pattern/index.md
JavaScript - Errors - Regex backslash at end of pattern - Error type: `SyntaxError`
[ -0.4655087888240814, 0.22353044152259827, -0.4449935257434845, -1.1619051694869995, -0.7408112287521362, -0.6575019359588623, 0.8444740772247314, 1.8927972316741943, -0.14871670305728912, -0.8823392391204834, 0.03786492347717285, -0.009104725904762745, -0.04426972568035126, 0.1666135638952...
javascript/reference/errors/regex_backslash_at_end_of_pattern/index.md
JavaScript - Errors - Regex backslash at end of pattern - What went wrong?: A backslash cannot appear literally in a regular expression. It either precedes another character to escape it, or is itself escaped by another backslash. A backslash at the end of a regular expression pattern is invalid because it is not esca...
[ 0.17356173694133759, 0.704794704914093, -0.30201005935668945, -0.724388837814331, -0.01293330080807209, -0.9395654201507568, 0.08199722319841385, 0.8837496042251587, -0.08552079647779465, -0.2277097851037979, -1.2216796875, -0.5057763457298279, -0.08005297183990479, -0.17761319875717163, ...
javascript/reference/errors/regex_backslash_at_end_of_pattern/index.md
JavaScript - Errors - Regex backslash at end of pattern - Examples - Double-escaping backslashes: This error can only happen when using the `RegExp()` constructor. Consider the following code, which intends to match a single backslash character: Example: const pattern = new RegExp("\\"); In JavaScript strings, back...
[ -1.5693632364273071, -0.05866794288158417, -0.6032771468162537, -0.24261704087257385, 0.37823399901390076, -0.5434950590133667, 0.2794172763824463, 0.7074586153030396, -0.3247736692428589, -0.26686733961105347, -0.9350849986076355, -0.21318697929382324, -0.3183799386024475, -0.702167987823...
javascript/reference/errors/parameter_after_rest_parameter/index.md
JavaScript - Errors - Parameter after rest parameter: The JavaScript exception "parameter after rest parameter" occurs when a rest parameter is followed by anything else in a parameter list, including another rest parameter, a formal parameter, or a trailing comma.
[ -0.1546892672777176, -0.05325033515691757, -2.0138096809387207, 0.6901060342788696, -0.49554458260536194, -1.425734043121338, 0.2762922942638397, 0.8227561712265015, -1.0980497598648071, -0.6527127623558044, -0.4504792392253876, -0.4704546332359314, -0.08700627088546753, 0.0059212283231318...
javascript/reference/errors/parameter_after_rest_parameter/index.md
JavaScript - Errors - Parameter after rest parameter - Message: Example: SyntaxError: Rest parameter must be last formal parameter (V8-based) SyntaxError: parameter after rest parameter (Firefox) SyntaxError: Unexpected token ','. Rest parameter should be the last parameter in a function declaration. (Safari)
[ -0.39186716079711914, 0.2466854453086853, -1.4725596904754639, 0.048784542828798294, -0.976119339466095, -1.4572744369506836, 0.7940221428871155, 0.5298708081245422, -0.10825570672750473, -0.9147418141365051, 0.5209818482398987, 0.2138586789369583, 0.05637657269835472, 0.003150764387100935...
javascript/reference/errors/parameter_after_rest_parameter/index.md
JavaScript - Errors - Parameter after rest parameter - Error type: `SyntaxError`
[ -0.17942717671394348, 0.007858897559344769, -1.2769372463226318, 0.12162598967552185, -0.8752584457397461, -0.9346928596496582, 1.2950879335403442, 1.9973114728927612, -0.3745098412036896, -1.22807776927948, 0.33051782846450806, 0.2137759029865265, 0.14975416660308838, -0.00676892092451453...
javascript/reference/errors/parameter_after_rest_parameter/index.md
JavaScript - Errors - Parameter after rest parameter - What went wrong?: A rest parameter must be the last parameter in a function definition. This is because the rest parameter collects all the remaining arguments passed to the function, so it doesn't make sense to have any parameters after it. The next non-whitespac...
[ 0.10121007263660431, 0.29040032625198364, -1.7929593324661255, 0.08958973735570908, -0.3194432258605957, -1.1121900081634521, 0.6674013137817383, 0.43857425451278687, -0.08079587668180466, -0.24635693430900574, -0.4897916615009308, 0.27671635150909424, 0.22113420069217682, 0.34634435176849...
javascript/reference/errors/parameter_after_rest_parameter/index.md
JavaScript - Errors - Parameter after rest parameter - Examples - Invalid cases: Example: function replacer(match, ...groups, offset, string) {} function doSomething( arg1, arg2, ...otherArgs, // Accidental trailing comma ) {}
[ -0.01157150138169527, 0.021413370966911316, -1.6314167976379395, 0.5728051066398621, -0.1731710582971573, -1.5852357149124146, 0.7388865947723389, 1.0474408864974976, -1.9317342042922974, -0.717790424823761, -0.13196618854999542, -0.2598044276237488, -0.17512711882591248, -0.39776757359504...
javascript/reference/errors/parameter_after_rest_parameter/index.md
JavaScript - Errors - Parameter after rest parameter - Examples - Valid cases: Example: function replacer(match, ...args) { const offset = args.at(-2); const string = args.at(-1); } function doSomething(arg1, arg2, ...otherArgs) {}
[ 0.19210176169872284, -0.22230663895606995, -1.7437503337860107, 0.601366400718689, -0.36951082944869995, -1.3739840984344482, 0.6353568434715271, 0.5725306272506714, -0.7983826994895935, -1.0297578573226929, -0.25184836983680725, -0.3281524181365967, -0.5859517455101013, -0.262028366327285...
javascript/reference/errors/cant_set_prototype/index.md
JavaScript - Errors - Cant set prototype: The JavaScript exception "can't set prototype of this object" occurs when attempting to set the prototype of an object, but the object's prototype is frozen, either by being a built-in immutable prototype object, or by being non-extensible.
[ -0.31155815720558167, -0.02075096219778061, -0.7027581334114075, 0.9174275398254395, -0.42398735880851746, -1.2165852785110474, 0.46814486384391785, 1.3277841806411743, 0.32360801100730896, -0.6211382746696472, -0.27320215106010437, -0.6876620650291443, -0.23139998316764832, -0.24597343802...
javascript/reference/errors/cant_set_prototype/index.md
JavaScript - Errors - Cant set prototype - Message: Example: TypeError: Immutable prototype object 'Object.prototype' cannot have their prototype set (V8-based) TypeError: #<Object> is not extensible (V8-based) TypeError: can't set prototype of this object (Firefox) TypeError: Cannot set prototype of immutable protot...
[ -1.468261480331421, 0.44272953271865845, -0.759262204170227, 0.0811593234539032, -0.7540286183357239, -1.1145635843276978, 0.47330549359321594, 1.0328096151351929, 0.5371429920196533, -0.17198704183101654, -0.02478971518576145, -0.6512113809585571, -0.15496301651000977, -1.1127994060516357...
javascript/reference/errors/cant_set_prototype/index.md
JavaScript - Errors - Cant set prototype - Error type: `TypeError`
[ -0.10376009345054626, 0.054751355201005936, -0.9273089170455933, -0.5290115475654602, -0.8280104398727417, 0.5016278624534607, 0.7354526519775391, 1.9453233480453491, 0.02429075352847576, -0.5291907787322998, 0.6593002676963806, -0.7052863240242004, 0.025166407227516174, -0.551193416118621...
javascript/reference/errors/cant_set_prototype/index.md
JavaScript - Errors - Cant set prototype - What went wrong?: You are using one of the prototype-mutating methods—most notably, `Object.setPrototypeOf()`—on an object whose prototype is immutable. Some built-in objects have immutable prototypes, such as `Object.prototype` and `window`, for security reasons. User object...
[ -1.0515202283859253, 0.309083491563797, -0.8433976769447327, 0.4627031683921814, -0.2647554278373718, -1.3568390607833862, 0.41341838240623474, 1.7006453275680542, 0.2880813777446747, 0.31102675199508667, -0.3043951392173767, -0.6022354960441589, -0.09425513446331024, -0.7284124493598938, ...
javascript/reference/errors/cant_set_prototype/index.md
JavaScript - Errors - Cant set prototype - Examples - Changing the prototype of a built-in object: A selected few built-in objects have immutable prototypes. For example, you cannot change the prototype of `Object.prototype`: Example: Object.setPrototypeOf(Object.prototype, {}); This prevents you from being able to...
[ -0.7048835158348083, 0.28767597675323486, -0.501191258430481, 0.6183616518974304, -0.30286046862602234, -2.177006483078003, 0.3313685655593872, 1.466294765472412, 0.04608006402850151, -0.29626014828681946, -0.19372975826263428, -0.8215668201446533, -0.5802372694015503, -0.7833800315856934,...
javascript/reference/errors/cant_set_prototype/index.md
JavaScript - Errors - Cant set prototype - Examples - Changing the prototype of a non-extensible object: If you make an object non-extensible, you cannot change its prototype either: Example: const obj = {}; Object.preventExtensions(obj); Object.setPrototypeOf(obj, {}); // TypeError: can't set prototype of this obje...
[ -0.8499149680137634, 0.3270536959171295, -0.5501406192779541, 0.26549282670021057, -0.8239708542823792, -1.6221548318862915, -0.09076175093650818, 1.127921223640442, 0.5682418346405029, -0.7048606276512146, -0.003699933411553502, -0.6285372972488403, -0.1985739767551422, -1.018762707710266...
javascript/reference/errors/illegal_character/index.md
JavaScript - Errors - Illegal character: The JavaScript exception "illegal character" occurs when the lexer reads a character that's not part of a string literal, and the character cannot constitute a valid token in the language.
[ -0.9533268809318542, 0.38131895661354065, -0.020649056881666183, -0.4600854218006134, -0.357093870639801, -0.15136688947677612, -0.1316576600074768, -0.09643109887838364, -0.02034553699195385, -0.5155027508735657, -0.43968749046325684, -0.4971977472305298, -0.9711494445800781, -1.135145902...
javascript/reference/errors/illegal_character/index.md
JavaScript - Errors - Illegal character - Message: Example: SyntaxError: Invalid or unexpected token (V8-based) SyntaxError: illegal character U+201C (Firefox) SyntaxError: Invalid character '\u201c' (Safari)
[ -0.8128894567489624, 0.5796184539794922, -0.2718257009983063, -0.600678563117981, -0.13423293828964233, -1.3272485733032227, 0.7673732042312622, 0.8856838941574097, -0.3770269453525543, -0.4594029486179352, 0.24511878192424774, -0.28417637944221497, -0.44828781485557556, -1.018974184989929...
javascript/reference/errors/illegal_character/index.md
JavaScript - Errors - Illegal character - Error type: `SyntaxError`
[ -0.3970632553100586, 0.28773000836372375, -0.2312133014202118, -0.3972536325454712, -0.771144688129425, -0.39764782786369324, 1.256118655204773, 1.7075787782669067, -0.4008171558380127, -0.7711532711982727, 0.12265671789646149, -0.07615915685892105, -0.60965895652771, -0.8550525307655334, ...
javascript/reference/errors/illegal_character/index.md
JavaScript - Errors - Illegal character - What went wrong?: There is an invalid character that the interpreter doesn't understand. You should either put it in a string literal or replace it with another character. Use an editor that supports syntax highlighting and carefully check your code against mismatches like a m...
[ -0.6988013982772827, -0.028647787868976593, 0.46482962369918823, -0.7859581708908081, 0.5547319650650024, -1.73344886302948, 0.7520684599876404, 0.6614983677864075, -0.03225566819310188, 0.08463037014007568, -0.4903186559677124, -0.6528492569923401, -0.5571767687797546, -0.4844591021537781...
javascript/reference/errors/illegal_character/index.md
JavaScript - Errors - Illegal character - Examples - Mismatched characters: Some characters look similar, but will cause the parser to fail interpreting your code. Famous examples of this are quotes, the minus or semicolon (greek question mark (U+37e) looks same). Example: “This looks like a string”; // SyntaxError:...
[ -0.262991338968277, -0.060666702687740326, -0.39999955892562866, -0.3501600921154022, 0.356329083442688, -1.4487806558609009, 1.1537033319473267, 0.6367526650428772, 0.026418108493089676, 0.4982573091983795, -0.8857911825180054, -0.302381694316864, -0.6471897959709167, -0.7573182582855225,...
javascript/reference/errors/illegal_character/index.md
JavaScript - Errors - Illegal character - Examples - Forgotten characters: It's easy to forget a character here or there. Example: const operators = ["+", "-", ×", "÷"]; // SyntaxError: illegal character U+00D7 Add the missing quote for `"×"`. Example: const operators = ["+", "-", "×", "÷"];
[ -0.670518159866333, 0.29247432947158813, -1.027212381362915, -0.3964204788208008, 0.21594266593456268, -0.8967695236206055, 1.290463924407959, 1.5653259754180908, 0.1526435911655426, 0.07207091897726059, -0.6273011565208435, -0.7053479552268982, -0.6689846515655518, -0.5278038382530212, ...
javascript/reference/errors/illegal_character/index.md
JavaScript - Errors - Illegal character - Examples - Hidden characters: When copy pasting code from external sources, there might be invalid characters. Watch out! Example: const foo = "bar";​ // SyntaxError: illegal character When inspecting this code in an editor like VIM, you can see that there is actually a zer...
[ -0.7739964723587036, 0.3524705171585083, -0.34276673197746277, -0.001990435877814889, 0.05007818341255188, -0.9304720759391785, 0.9320744276046753, 0.4358137547969818, -0.15024973452091217, 1.0207678079605103, -0.6847896575927734, -0.1761123538017273, -0.7469125390052795, -1.16574203968048...
javascript/reference/errors/regex_raw_bracket/index.md
JavaScript - Errors - Regex raw bracket: The JavaScript exception "raw bracket is not allowed in regular expression with unicode flag" occurs when a Unicode-aware regular expression pattern contains a raw bracket (`{`, `}`, `]`) that is not part of a quantifier or character class.
[ -0.3561934232711792, 0.7980504035949707, -0.6814682483673096, -0.17478810250759125, -0.35214969515800476, -1.0397975444793701, 0.17755411565303802, 1.4494166374206543, -0.16120575368404388, -1.012195348739624, -0.8974426984786987, -0.8317176699638367, 0.8163713812828064, -0.581760823726654...
javascript/reference/errors/regex_raw_bracket/index.md
JavaScript - Errors - Regex raw bracket - Message: Example: SyntaxError: Invalid regular expression: /{/u: Lone quantifier brackets (V8-based) SyntaxError: raw bracket is not allowed in regular expression with unicode flag (Firefox) SyntaxError: Invalid regular expression: incomplete {} quantifier for Unicode pattern...
[ -0.5045490264892578, 0.8949553966522217, -0.9111559987068176, -0.7961258888244629, -0.544259250164032, -0.9602235555648804, 0.7144336700439453, 1.5211049318313599, -0.27543020248413086, -0.33674243092536926, -0.41586607694625854, -0.792591392993927, 0.9341534972190857, -0.7939164042472839,...
javascript/reference/errors/regex_raw_bracket/index.md
JavaScript - Errors - Regex raw bracket - Error type: `SyntaxError`
[ -0.3015633523464203, 0.42331430315971375, -0.059225402772426605, -0.6297457218170166, -0.6755569577217102, -0.4439924657344818, 0.9945391416549683, 2.7072408199310303, -0.12546123564243317, -0.981410562992096, -0.2178654670715332, -0.3115355372428894, 0.1555977314710617, -0.155329689383506...
javascript/reference/errors/regex_raw_bracket/index.md
JavaScript - Errors - Regex raw bracket - What went wrong?: In Unicode-unaware mode, `{`, `}`, and `]` that are not part of a quantifier or character class are treated as literal characters. This may hide errors in your code and is therefore deprecated and disallowed in Unicode-aware mode. You should either check whet...
[ -1.1387240886688232, 0.892546534538269, -0.4089937210083008, -0.8424815535545349, -0.06181043013930321, -0.9709294438362122, 1.2385292053222656, 2.123108386993408, 0.3076503276824951, -0.4372517168521881, -0.0810210257768631, -0.6907723546028137, 0.6005764007568359, -0.2800436317920685, ...
javascript/reference/errors/regex_raw_bracket/index.md
JavaScript - Errors - Regex raw bracket - Examples - Invalid cases: Example: /\{{MDN_Macro}}/u; /\[sic]/u;
[ -0.6019389629364014, 0.07835285365581512, -1.0483112335205078, -0.47542604804039, -0.2596149444580078, -0.18057650327682495, 0.36983293294906616, 1.164909839630127, -0.6604270935058594, 0.05353950709104538, -0.5952996015548706, -1.0454822778701782, 0.4696016311645508, -0.49903541803359985,...
javascript/reference/errors/regex_raw_bracket/index.md
JavaScript - Errors - Regex raw bracket - Examples - Valid cases: Example: // All { and } need to be escaped /\\{\\{MDN_Macro\\}\\}/u; // The ] needs to be escaped /\[sic\]/u;
[ 0.08020977675914764, 0.3151468336582184, -0.8251728415489197, -0.3310467004776001, -0.20138415694236755, -0.6821165084838867, 0.629152238368988, 0.7728502750396729, -0.0317058265209198, 0.18201623857021332, -0.9824077486991882, -1.1815342903137207, -0.2673908472061157, -0.05069801956415176...
javascript/reference/errors/no_properties/index.md
JavaScript - Errors - No properties: The JavaScript exception "null (or undefined) has no properties" occurs when you attempt to access properties of `null` and `undefined`. They don't have any.
[ -0.8989876508712769, 0.3898341953754425, -0.5950140953063965, 0.3478104770183563, -0.7504389882087708, -1.0180250406265259, 1.2734402418136597, 1.178719401359558, -0.38570669293403625, -0.4098227620124817, -0.5734829902648926, -1.2002629041671753, -0.13443821668624878, -0.36158469319343567...
javascript/reference/errors/no_properties/index.md
JavaScript - Errors - No properties - Message: Example: TypeError: 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) ...
[ -0.764900803565979, 0.6399832367897034, -0.4827369451522827, -0.4049457311630249, -0.8000583648681641, -0.4011123776435852, 1.3357057571411133, 0.7886354923248291, 0.5093654990196228, -0.1758129894733429, 0.31687143445014954, -1.184396743774414, -0.11775106191635132, -0.21132616698741913, ...
javascript/reference/errors/no_properties/index.md
JavaScript - Errors - No properties - Error type: `TypeError`.
[ -0.3495073616504669, 0.16221383213996887, -0.5463879704475403, -0.46855059266090393, -0.39463570713996887, 0.6999863982200623, 1.0073230266571045, 2.3797004222869873, -0.3494531512260437, -1.1226500272750854, 0.14669229090213776, -0.7030414938926697, 0.0004705536412075162, -0.4607257544994...
javascript/reference/errors/no_properties/index.md
JavaScript - Errors - No properties - What went wrong?: Both `null` and `undefined` have no properties you could access. Therefore, you cannot use property accessors on them, or destructure them.
[ -0.12658409774303436, 0.8162114024162292, -1.1987472772598267, 0.6734477281570435, -0.3169088363647461, -1.1126232147216797, 0.7572010159492493, 0.9032216668128967, 0.26383790373802185, 0.21280626952648163, -0.5503612160682678, -1.1383143663406372, 0.14290578663349152, -0.6014782190322876,...
javascript/reference/errors/no_properties/index.md
JavaScript - Errors - No properties - Examples - null and undefined have no properties: Example: null.foo; // TypeError: null has no properties undefined.bar; // TypeError: undefined has no properties
[ -0.514025092124939, 0.9999221563339233, -0.761466383934021, 0.12949343025684357, -0.5264152884483337, -0.7669566869735718, 1.261528491973877, 1.8454632759094238, -0.3963901102542877, -0.22140352427959442, 0.03101940080523491, -0.9239654541015625, 0.04501257464289665, -0.5550990104675293, ...
javascript/reference/errors/key_not_weakly_held/index.md
JavaScript - Errors - Key not weakly held: The 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` or as a value in a `WeakMap`.
[ 0.023919040337204933, 0.016873644664883614, -1.2496016025543213, -0.1305181235074997, -0.5776347517967224, -2.1262590885162354, 1.9046382904052734, 1.6561204195022583, -0.4778403341770172, -0.257780522108078, -0.35643553733825684, -0.6225714683532715, 0.23643609881401062, -0.41735735535621...
javascript/reference/errors/key_not_weakly_held/index.md
JavaScript - Errors - Key not weakly held - Message: Example: TypeError: 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 (V...
[ -0.08514843136072159, 0.2456914186477661, -1.848189353942871, -0.5378685593605042, -0.4936777949333191, -1.8814544677734375, 1.4903512001037598, 2.005836009979248, -0.5803728103637695, -0.040361471474170685, 0.1490076631307602, -0.24611997604370117, 0.20020882785320282, -0.6189236044883728...
javascript/reference/errors/key_not_weakly_held/index.md
JavaScript - Errors - Key not weakly held - Error type: `TypeError`
[ 0.1715833693742752, 0.3783413767814636, -1.4185361862182617, -0.8714504837989807, -0.7064553499221802, -0.09141776710748672, 1.5346750020980835, 2.4961092472076416, -0.44236209988594055, -0.4174357056617737, 0.2417074292898178, -0.2233717143535614, -0.36913827061653137, -0.2339063137769699...
javascript/reference/errors/key_not_weakly_held/index.md
JavaScript - Errors - Key not weakly held - What went wrong?: `WeakSet` and `WeakMap` require the keys to be garbage collectable. Only objects and non-registered symbols (that is, symbols not returned by `Symbol.for()`) are valid. For more information, see Memory management. If you want to add keys that are strings, n...
[ 0.14748351275920868, 0.28637298941612244, -1.0458849668502808, -0.03309901803731918, -0.056238215416669846, -2.7750179767608643, 1.9920307397842407, 1.6023149490356445, -0.7921281456947327, 0.405687153339386, -0.1708850860595703, 0.2765823006629944, 0.0371837355196476, 0.028591884300112724...
javascript/reference/errors/key_not_weakly_held/index.md
JavaScript - Errors - Key not weakly held - Examples - Invalid cases: Example: new WeakSet().add(1); // TypeError new WeakMap().set(1, {}); // TypeError new WeakSet([1]); // TypeError new WeakMap([[1, {}]]); // TypeError
[ -0.2902519106864929, 0.5101056098937988, -1.3355848789215088, -0.39771777391433716, 0.042531583458185196, -1.5092167854309082, 1.5247974395751953, 2.451671838760376, -0.7100542783737183, 0.001978237647563219, -0.24486809968948364, -0.3907724618911743, -0.12396026402711868, -0.1432538777589...
javascript/reference/errors/key_not_weakly_held/index.md
JavaScript - Errors - Key not weakly held - Examples - Valid cases: Example: new WeakSet().add({}); // OK new WeakMap().set({}, 1); // OK new Set([1]); // OK new Map([[1, {}]]); // OK
[ 0.24650105834007263, 0.5377793908119202, -1.4687496423721313, -0.5906301736831665, 0.08238860219717026, -1.7276644706726074, 1.6115994453430176, 2.1872384548187256, -0.5824925303459167, 0.19947580993175507, -0.37912729382514954, -0.305799275636673, 0.06582695245742798, 0.11555232852697372,...
javascript/reference/errors/cant_delete/index.md
JavaScript - Errors - Cant delete: The JavaScript exception "property is non-configurable and can't be deleted" occurs when it was attempted to delete a property, but that property is non-configurable.
[ -0.29009953141212463, 0.851763129234314, -0.9904937148094177, 0.4006505012512207, -0.5136145949363708, -1.559785008430481, 0.6288159489631653, 1.0849595069885254, 0.2285933643579483, 0.03756029158830643, -0.23952727019786835, -0.6486347913742065, -0.8843043446540833, -0.235105499625206, ...
javascript/reference/errors/cant_delete/index.md
JavaScript - Errors - Cant delete - Message: Example: TypeError: Cannot delete property 'x' of #<Object> (V8-based) TypeError: property "x" is non-configurable and can't be deleted (Firefox) TypeError: Unable to delete property. (Safari)
[ -0.8078628182411194, 0.3156888782978058, -1.2173161506652832, -0.36360105872154236, -0.742391049861908, -1.2392621040344238, 0.8674193620681763, 1.249848484992981, 0.2884269654750824, -0.6580936908721924, 0.4750649631023407, -0.46752405166625977, -0.4876101016998291, -0.39564961194992065, ...
javascript/reference/errors/cant_delete/index.md
JavaScript - Errors - Cant delete - Error type: `TypeError` in strict mode only.
[ -0.42654523253440857, -0.024768978357315063, -0.7402819395065308, -0.153675839304924, -0.5858433842658997, 0.2970944046974182, 0.4343019127845764, 1.8921864032745361, -0.06747971475124359, -0.6394476294517517, -0.023049628362059593, -0.9892616868019104, -0.33244746923446655, -0.11681204289...
javascript/reference/errors/cant_delete/index.md
JavaScript - Errors - Cant delete - What went wrong?: It was attempted to delete a property, but that property is non-configurable. The `configurable` attribute controls whether the property can be deleted from the object and whether its attributes (other than `writable`) can be changed. This error happens only in st...
[ -0.8760290741920471, 0.6484309434890747, -0.671424388885498, 0.025696922093629837, -0.33942005038261414, -1.4592368602752686, 0.24573327600955963, 1.1755682229995728, 0.31754329800605774, 0.2481173723936081, -0.5295451879501343, -0.6762517094612122, -0.7305006384849548, 0.01661793887615204...
javascript/reference/errors/cant_delete/index.md
JavaScript - Errors - Cant delete - Examples - Attempting to delete non-configurable properties: Non-configurable properties are not super common, but they can be created using `Object.defineProperty()` or `Object.freeze()`. Example: "use strict"; const obj = Object.freeze({ name: "Elsa", score: 157 }); delete obj.s...
[ -1.037488341331482, 0.28752371668815613, -0.9155464768409729, 0.5415185689926147, 0.34054091572761536, -1.2390260696411133, 1.2178080081939697, 0.7092136740684509, 0.06377515941858292, 0.7922115325927734, -0.32144591212272644, -0.17954283952713013, 0.0825754851102829, -0.3322433829307556, ...
javascript/reference/functions/index.md
JavaScript - Functions: Generally speaking, a function is a "subprogram" that can be called by code external (or internal, in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the function body. Values can be passed to a function as parameters, a...
[ -0.013286835514008999, -0.21402157843112946, -1.2927610874176025, 0.8306960463523865, 0.14146050810813904, -1.023653507232666, 0.6889728903770447, 0.6069208979606628, -0.3554956316947937, -0.4163084328174591, -0.8802913427352905, -0.4049549996852875, -0.7672821283340454, 0.6526485085487366...
javascript/reference/functions/index.md
JavaScript - Functions - Description: Function values are typically instances of `Function`. See `Function` for information on properties and methods of `Function` objects. Callable values cause `typeof` to return `"function"` instead of `"object"`. Note: Not all callable values are `instanceof Function`. For example...
[ -0.6397064924240112, -0.306054025888443, -1.2216309309005737, 0.5678873062133789, 0.10162579268217087, -0.9969900846481323, 0.0174751915037632, 0.9213979840278625, -0.149436354637146, -0.20625829696655273, -0.17543038725852966, 0.002269053366035223, 0.290987491607666, 0.07419894635677338, ...
javascript/reference/functions/index.md
JavaScript - Functions - Description - Return value: By default, if a function's execution doesn't end at a `return` statement, or if the `return` keyword doesn't have an expression after it, then the return value is `undefined`. The `return` statement allows you to return an arbitrary value from the function. One fun...
[ -0.5002493262290955, 0.22925035655498505, -1.3321558237075806, 0.6882510781288147, -0.5894607305526733, -0.19748161733150482, 0.4798033833503723, 1.018165111541748, -0.3777284324169159, 0.05981903523206711, -0.12542466819286346, -0.04885721579194069, -0.04638485610485077, 0.326566576957702...
javascript/reference/functions/index.md
JavaScript - Functions - Description - Passing arguments: Parameters and arguments have slightly different meanings, but in MDN web docs, we often use them interchangeably. For a quick reference: Example: function formatNumber(num) { return num.toFixed(2); } formatNumber(2); In this example, the `num` variable i...
[ -0.6398760676383972, -0.9016771912574768, -1.4699968099594116, 0.4323485791683197, -0.29820460081100464, -1.86222505569458, 1.0705116987228394, 0.43528521060943604, -0.09326361864805222, 0.02289796806871891, -0.2456282675266266, 0.21103203296661377, -0.30036577582359314, 0.6488124132156372...
javascript/reference/functions/index.md
JavaScript - Functions - Description - Defining functions: Broadly speaking, JavaScript has four kinds of functions: - Regular function: can return anything; always runs to completion after invocation - Generator function: returns a `Generator` object; can be paused and resumed with the `yield` operator - Async funct...
[ 0.41373211145401, -0.2684597969055176, -0.7895119786262512, 0.6305409073829651, 0.7238973379135132, -0.9861941933631897, 0.270503431558609, 1.1058987379074097, -0.5036545991897583, 0.00052460195729509, 0.2847757339477539, 0.38986560702323914, 0.3714893162250519, 0.3124951720237732, -0.35...
javascript/reference/functions/index.md
JavaScript - Functions - Description - Function parameters: Each function parameter is a simple identifier that you can access in the local scope. Example: function myFunc(a, b, c) { // You can access the values of a, b, and c here } There are three special parameter syntaxes: - Default parameters allow formal p...
[ -0.07296683639287949, 0.09499391168355942, -1.9583256244659424, 0.8511388301849365, -0.06781807541847229, -1.238411784172058, 1.1861600875854492, 0.21950015425682068, 0.3979206383228302, -0.01987617462873459, -0.9402908086776733, 0.28097525238990784, 0.008253788575530052, -0.07969410717487...
javascript/reference/functions/index.md
JavaScript - Functions - Description - The arguments object: You can refer to a function's arguments within the function by using the `arguments` object. - `arguments`: An array-like object containing the arguments passed to the currently executing function. - `arguments.callee`: The currently executing function. - `...
[ -0.015473243780434132, -0.2908363342285156, -1.2684845924377441, 1.148224115371704, -0.11099496483802795, -2.482076644897461, 0.2763618528842926, 0.6067503094673157, -0.28373071551322937, 0.13719089329242706, -0.14725026488304138, -0.3090318739414215, -0.06912080198526382, 0.64181035757064...
javascript/reference/functions/index.md
JavaScript - Functions - Description - Getter and setter functions: You can define accessor properties on any standard built-in object or user-defined object that supports the addition of new properties. Within object literals and classes, you can use special syntaxes to define the getter and setter of an accessor pro...
[ -0.6516837477684021, -0.13143537938594818, -1.566598892211914, 1.0854192972183228, -0.03456740826368332, -1.5622726678848267, 0.3316705822944641, 0.8260735273361206, 0.6012311577796936, -0.11030037701129913, -0.3437366485595703, 0.025875508785247803, -0.3854496479034424, 0.2625363171100616...
javascript/reference/functions/index.md
JavaScript - Functions - Description - Block-level functions: In strict mode, functions inside blocks are scoped to that block. Prior to ES2015, block-level functions were forbidden in strict mode. Example: "use strict"; function f() { return 1; } { function f() { return 2; } } f() === 1; // true // f(...
[ -0.14392352104187012, -0.4596423804759979, -1.433687686920166, 0.3054584860801697, 0.4402814209461212, -1.106633186340332, 0.5653941631317139, 1.0021121501922607, -0.25716736912727356, 0.2908605635166168, -0.6266093254089355, 0.2536574900150299, 0.09505610913038254, 0.6408630609512329, 0...
javascript/reference/functions/index.md
JavaScript - Functions - Description - Block-level functions in non-strict code: In a word: Don't. In non-strict code, function declarations inside blocks behave strangely. For example: Example: if (shouldDefineZero) { function zero() { // DANGER: compatibility risk console.log("This is zero."); } } Th...
[ -0.40757811069488525, -0.09277486056089401, -1.477798581123352, 0.9348160028457642, -0.0922926664352417, -0.639657735824585, 1.079553484916687, 0.40345078706741333, -0.6970404982566833, 0.3139055371284485, -0.2583891451358795, -0.835963249206543, -0.08833256363868713, 0.03301434963941574, ...
javascript/reference/functions/index.md
JavaScript - Functions - Examples - Returning a formatted number: The following function returns a string containing the formatted representation of a number padded with leading zeros. Example: // This function returns a string padded with leading zeros function padZeros(num, totalLen) { let numStr = num.toString(...
[ -0.5260539054870605, 0.43310248851776123, -1.3922443389892578, -0.3745817542076111, -0.5477854013442993, -0.5735572576522827, 1.603615641593933, 1.2937957048416138, -1.0333188772201538, 0.4340847134590149, -1.1884326934814453, 0.11469916999340057, -0.7915019392967224, 0.19473636150360107, ...
javascript/reference/functions/index.md
JavaScript - Functions - Examples - Determining whether a function exists: You can determine whether a function exists by using the `typeof` operator. In the following example, a test is performed to determine if the `window` object has a property called `noFunc` that is a function. If so, it is used; otherwise, some ...
[ -1.2587435245513916, -0.2758737802505493, -0.7737731337547302, 0.6357593536376953, -0.29014357924461365, -0.22780801355838776, 1.39301335811615, 1.4523825645446777, 0.7383681535720825, 0.18199731409549713, -0.174156054854393, -0.952183187007904, -0.5255297422409058, -0.18141567707061768, ...
javascript/reference/functions/arguments/index.md
JavaScript - Functions - arguments: `arguments` is an array-like object accessible inside functions that contains the values of the arguments passed to that function. Example: function func1(a, b, c) { console.log(arguments[0]); // Expected output: 1 console.log(arguments[1]); // Expected output: 2 conso...
[ 0.277850866317749, -0.4414041042327881, -1.323621153831482, 1.0055958032608032, -0.2582402229309082, -2.385294198989868, 0.2881673276424408, 1.2645360231399536, 0.291147917509079, -0.3379928171634674, -0.03265661373734474, -0.024239011108875275, 0.3488878607749939, -0.00569754745811224, ...
javascript/reference/functions/arguments/index.md
JavaScript - Functions - arguments - Description: Note: In modern code, rest parameters should be preferred. The `arguments` object is a local variable available within all non-arrow functions. You can refer to a function's arguments inside that function by using its `arguments` object. It has entries for each argume...
[ -0.14277823269367218, -0.010623197071254253, -1.0099494457244873, 1.0177526473999023, -0.15903963148593903, -1.7925437688827515, 0.7798429131507874, -0.24571450054645538, -0.533162534236908, 0.19963005185127258, -0.5628960728645325, 0.3165092170238495, 0.720445990562439, 0.2467617392539978...
javascript/reference/functions/arguments/index.md
JavaScript - Functions - arguments - Description - Assigning to indices: Each argument index can also be set or reassigned: Example: arguments[1] = "new value"; Non-strict functions that only have simple parameters (that is, no rest, default, or destructured parameters) will sync the new value of parameters with th...
[ -0.13926108181476593, -0.348844438791275, -0.8915228247642517, 0.7149187922477722, 0.7176828384399414, -1.0475385189056396, 0.3652709126472473, 0.32631027698516846, 0.06581255793571472, -0.2722874581813812, 0.10170207917690277, 0.07944570481777191, -0.2540505826473236, 1.0172040462493896, ...
javascript/reference/functions/arguments/index.md
JavaScript - Functions - arguments - Description - arguments is an array-like object: `arguments` is an array-like object, which means that `arguments` has a `length` property and properties indexed from zero, but it doesn't have `Array`'s built-in methods like `forEach()` or `map()`. However, it can be converted to a...
[ -0.10125793516635895, -0.20657984912395477, -0.4927489459514618, 0.8234435319900513, -0.3852890133857727, -1.8982106447219849, 0.676750659942627, 0.8660085797309875, 0.22580085694789886, 0.18544131517410278, -0.6416075229644775, -0.001567903091199696, -0.06022045388817787, 0.11250218003988...
javascript/reference/functions/arguments/index.md
JavaScript - Functions - arguments - Properties: - `arguments.callee` (deprecated): Reference to the currently executing function that the arguments belong to. Forbidden in strict mode. - `arguments.length`: The number of arguments that were passed to the function. - `arguments[Symbol.iterator]()`: Returns a new array...
[ -0.367732435464859, -0.4385049343109131, -0.8499479293823242, 0.4666152000427246, -0.011151717975735664, -2.453298330307007, 0.6414687037467957, 0.9587002992630005, -0.4984669089317322, 0.6602829694747925, -0.5662416219711304, -0.08853045105934143, -0.6511741876602173, 0.7044334411621094, ...
javascript/reference/functions/arguments/index.md
JavaScript - Functions - arguments - Examples - Defining a function that concatenates several strings: This example defines a function that concatenates several strings. The function's only formal argument is a string containing the characters that separate the items to concatenate. Example: function myConcat(separa...
[ -0.17933297157287598, -0.6021101474761963, -1.5954617261886597, 0.1813855767250061, -0.16716043651103973, -1.699924111366272, -0.015548715367913246, 0.692844808101654, 0.09101404994726181, -0.31109151244163513, -0.14229480922222137, 0.09074591845273972, -0.7727263569831848, 0.1013428345322...
javascript/reference/functions/arguments/index.md
JavaScript - Functions - arguments - Examples - Defining a function that creates HTML lists: This example defines a function that creates a string containing HTML for a list. The only formal argument for the function is a string that is `"u"` if the list is to be unordered (bulleted), or `"o"` if the list is to be ord...
[ -0.9403206706047058, -0.73633873462677, -1.0560011863708496, 0.3637275695800781, 0.5016470551490784, -1.4815318584442139, 0.11196456104516983, 0.7931244969367981, 0.036707378923892975, 0.07364436239004135, 0.09947994351387024, 0.07570889592170715, -0.012022063136100769, -0.5281086564064026...
javascript/reference/functions/arguments/index.md
JavaScript - Functions - arguments - Examples - Using typeof with arguments: The `typeof` operator returns `'object'` when used with `arguments` Example: console.log(typeof arguments); // 'object' The type of individual arguments can be determined by indexing `arguments`: Example: console.log(typeof arguments[0])...
[ -0.40127134323120117, -0.519874095916748, -0.40893685817718506, 0.9390670657157898, -0.5810593962669373, -0.9814231991767883, 1.2818212509155273, 0.5927554965019226, 0.6147617101669312, -0.5414358377456665, -0.15540866553783417, -0.3192760646343231, 0.42134207487106323, -0.7276775240898132...
javascript/reference/functions/arguments/symbol.iterator/index.md
JavaScript - Functions - arguments - Symbol.iterator: The `[Symbol.iterator]()` method of `arguments` objects implements the iterable protocol and allows `arguments` objects to be consumed by most syntaxes expecting iterables, such as the spread syntax and `for...of` loops. It returns an array iterator object that yie...
[ -0.08901871740818024, -0.38442718982696533, -0.6005486249923706, 1.012925386428833, -0.03358040750026703, -1.8511096239089966, 0.23255831003189087, 1.4735369682312012, -0.14639902114868164, 0.04485532268881798, -0.4970328211784363, 0.5209757089614868, -0.41999292373657227, 0.25204381346702...
javascript/reference/functions/arguments/symbol.iterator/index.md
JavaScript - Functions - arguments - Symbol.iterator - Syntax: Example: arguments[Symbol.iterator]()
[ 0.23163287341594696, 0.00009528711234452203, -0.4035186469554901, -0.01500020269304514, -0.6590391397476196, -2.188544511795044, 0.5767602324485779, 1.981114387512207, 0.5690075755119324, -0.4717898964881897, -0.026608245447278023, 0.28394514322280884, -0.7713515162467957, -0.2502393126487...
javascript/reference/functions/arguments/symbol.iterator/index.md
JavaScript - Functions - arguments - Symbol.iterator - Syntax - Parameters: None.
[ 0.22367160022258759, 0.24314774572849274, -0.6493924856185913, -0.26666685938835144, -0.45899227261543274, -1.2545406818389893, 0.7569807767868042, 2.333477735519409, 0.04982946440577507, -0.4467341899871826, -0.4609518349170685, -0.3382217586040497, -0.448567271232605, 0.16198787093162537...
javascript/reference/functions/arguments/symbol.iterator/index.md
JavaScript - Functions - arguments - Symbol.iterator - Syntax - Return value: The same return value as `Array.prototype.values()`: a new iterable iterator object that yields the value of each index in the `arguments` object.
[ -0.08898889273405075, -0.4334757626056671, -0.7075568437576294, 0.822132408618927, -0.4203573167324066, -1.4293830394744873, 0.3454354405403137, 1.7732324600219727, -0.09658639878034592, 0.14469628036022186, -0.49931880831718445, 0.3414043188095093, -0.10299980640411377, 0.6789994835853577...
javascript/reference/functions/arguments/symbol.iterator/index.md
JavaScript - Functions - arguments - Symbol.iterator - Examples - Iteration using for...of loop: Note that you seldom need to call this method directly. The existence of the `[Symbol.iterator]()` method makes `arguments` objects iterable, and iterating syntaxes like the `for...of` loop automatically call this method t...
[ -0.2714758515357971, 0.07779863476753235, 0.1670975387096405, 0.4971224069595337, 0.5241815447807312, -1.038368582725525, 0.3829236328601837, 0.4764308035373688, -0.5233978629112244, -0.1857263743877411, 0.10096599906682968, 0.4193267524242401, -0.5464094877243042, 0.5090481042861938, 0....
javascript/reference/functions/arguments/symbol.iterator/index.md
JavaScript - Functions - arguments - Symbol.iterator - Examples - Manually hand-rolling the iterator: You may still manually call the `next()` method of the returned iterator object to achieve maximum control over the iteration process. Example: function f() { const argsIter = arguments[Symbol.iterator](); conso...
[ -0.29728633165359497, -0.11116332560777664, -0.5748556852340698, 0.29263678193092346, 0.06481336057186127, -1.4679933786392212, -0.22541196644306183, 0.36551743745803833, -0.30660584568977356, 0.9579861760139465, -0.002193782478570938, 0.4918900728225708, -0.40244799852371216, -0.105171032...
javascript/reference/functions/arguments/length/index.md
JavaScript - Functions - arguments - length: The `arguments.length` data property contains the number of arguments passed to the function.
[ -0.332139790058136, -0.9107008576393127, -1.3329877853393555, 0.9774680137634277, -0.965694785118103, -2.142937421798706, 0.5655938386917114, 0.7695839405059814, -0.03979925438761711, -0.9568119645118713, -0.6915680170059204, -0.03404082730412483, 0.04808490350842476, 0.3819527328014374, ...
javascript/reference/functions/arguments/length/index.md
JavaScript - Functions - arguments - length - Value: A non-negative integer.
[ -0.7241860628128052, -0.8139111995697021, -1.0333142280578613, 0.09177249670028687, -0.7151311635971069, -1.1137663125991821, 1.5999001264572144, 0.893511950969696, -0.39578330516815186, -0.07062035799026489, -0.7200337052345276, -0.5896130800247192, -0.03981202840805054, -0.21705812215805...
javascript/reference/functions/arguments/length/index.md
JavaScript - Functions - arguments - length - Description: The `arguments.length` property provides the number of arguments actually passed to a function. This can be more or less than the defined parameter's count (see `Function.prototype.length`). For example, for the function below: Example: function func1(a, b, ...
[ -0.3516208529472351, -0.6075547337532043, -1.5397765636444092, 0.5062587261199951, -0.2630667984485626, -2.28946590423584, -0.0354606918990612, 0.3620910942554474, -0.21131211519241333, -0.4568679630756378, -0.47614026069641113, 0.04106588289141655, 0.36008119583129883, 0.3675050139427185,...
javascript/reference/functions/arguments/length/index.md
JavaScript - Functions - arguments - length - Examples - Using arguments.length: In this example, we define a function that can add two or more numbers together. Example: function adder(base /*, num1, …, numN */) { base = Number(base); for (let i = 1; i < arguments.length; i++) { base += Number(arguments[i])...
[ 0.4656297564506531, -0.31768888235092163, -1.208526611328125, 0.6740384697914124, -0.5312599539756775, -1.6134511232376099, 0.6400565505027771, 0.5255687236785889, 0.061340659856796265, -0.5126860737800598, -1.2064235210418701, 0.504938006401062, -0.8504316210746765, 0.08581472933292389, ...
javascript/reference/functions/arguments/callee/index.md
JavaScript - Functions - arguments - callee: Deprecated: This feature is no longer recommended. Note: Accessing `arguments.callee` in strict mode will throw a `TypeError`. If a function must reference itself, either give the function expression a name or use a function declaration. The `arguments.callee` data proper...
[ -0.44584739208221436, 0.11897314339876175, -1.0665092468261719, 0.6640373468399048, -0.42102426290512085, -1.547350525856018, 1.4892796277999878, 0.7140069603919983, -0.4594956934452057, 0.223495215177536, -0.050468821078538895, -0.4360944926738739, -0.11007147282361984, 0.3627192080020904...
javascript/reference/functions/arguments/callee/index.md
JavaScript - Functions - arguments - callee - Value: A reference to the currently executing function. Note: `callee` is a data property only in non-strict functions with simple parameters (in which case the `arguments` object is also auto-syncing). Otherwise, it is an accessor property whose getter and setter both th...
[ -0.8507914543151855, -0.013148458674550056, -1.6895647048950195, 0.9939951300621033, 0.16279931366443634, -1.448947787284851, 0.8100824356079102, 1.9352701902389526, -0.4335286021232605, 0.1269032061100006, -0.00178124092053622, -0.920514702796936, -0.07789522409439087, 0.7514821290969849,...
javascript/reference/functions/arguments/callee/index.md
JavaScript - Functions - arguments - callee - Description: `callee` is a property of the `arguments` object. It can be used to refer to the currently executing function inside the function body of that function. This is useful when the name of the function is unknown, such as within a function expression with no name ...
[ 0.7266152501106262, -0.2388204038143158, -0.985277533531189, 0.8802499175071716, 1.2259154319763184, -1.1519544124603271, 0.4424792528152466, 0.4267030656337738, -0.7708284258842468, 0.5907396674156189, 0.018766295164823532, 0.6311004757881165, 0.35424357652664185, 0.49841970205307007, -...
javascript/reference/functions/arguments/callee/index.md
JavaScript - Functions - arguments - callee - Examples - Using arguments.callee in an anonymous recursive function: A recursive function must be able to refer to itself. Typically, a function refers to itself by its name. However, an anonymous function (which can be created by a function expression or the `Function` c...
[ -0.6334823369979858, 1.0389503240585327, -0.5999574661254883, 0.6525673866271973, 0.12102161347866058, -1.1284996271133423, 1.01603102684021, 0.34943732619285583, -1.3382681608200073, 0.7449730634689331, -0.30599361658096313, -0.27006399631500244, -0.7953311204910278, 0.19362597167491913, ...
javascript/reference/functions/arguments/callee/index.md
JavaScript - Functions - arguments - callee - Examples - Recursion of anonymous functions with a Y-combinator: Although function expressions can now be named, arrow functions always remain anonymous, which means they cannot reference themselves without being assigned to a variable first. Fortunately, in Lambda calculu...
[ -1.1016054153442383, -0.24471071362495422, -1.0974429845809937, 0.2478141188621521, 0.3226042687892914, -1.2647349834442139, 1.5253840684890747, 0.9333112835884094, 0.07281891256570816, 1.012962818145752, -0.39926671981811523, 0.5370163321495056, -0.3409785330295563, 0.10451579838991165, ...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions: Method definition is a shorter syntax for defining a function property in an object initializer. It can also be used in classes. Example: const obj = { foo() { return "bar"; }, }; console.log(obj.foo()); // Expected output: "bar"
[ 0.6739531755447388, -0.7034264206886292, -1.931624174118042, 0.30849671363830566, 0.1384333074092865, -1.6436617374420166, -0.24786494672298431, 1.836715817451477, 0.4257853329181671, 0.1873806267976761, -0.8062227368354797, -0.4888761043548584, 0.8647585511207581, -0.29218927025794983, ...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Syntax: Example: ({ property(parameters) {}, *generator(parameters) {}, async property(parameters) {}, async *generator(parameters) {}, // with computed keys [expression](parameters) {}, *[expression](parameters) {}, async [expression](parameters) {}, a...
[ 0.8833812475204468, 0.01281583122909069, -0.9424594640731812, 0.3631647825241089, -0.7994176745414734, -1.4408245086669922, 0.8180472254753113, 2.227628707885742, 0.598718523979187, 0.0913153737783432, -0.3846222460269928, 0.5545822978019714, 0.03125244751572609, -0.10906169563531876, -0...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Description: The shorthand syntax is similar to the getter and setter syntax. Given the following code: Example: const obj = { foo: function () { // … }, bar: function () { // … }, }; You are now able to shorten this to: Example: const obj = { foo()...
[ 0.2787013649940491, -0.08968886733055115, -1.9990520477294922, 0.28979620337486267, 0.18617768585681915, -2.2005326747894287, 0.40726009011268616, 1.8535027503967285, 0.4701394736766815, 0.4852399230003357, -0.7177900671958923, 0.44660672545433044, 0.39140892028808594, -0.21949952840805054...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Description - Method definitions are not constructable: Methods cannot be constructors! They will throw a `TypeError` if you try to instantiate them. On the other hand, a property created as a function can be used as a constructor. Example: const obj = { method() {}, }...
[ 0.7153987288475037, -0.3011459708213806, -1.1043621301651, 0.5375701785087585, -0.13395540416240692, -1.5782556533813477, -0.5849158763885498, 1.6008350849151611, 0.1479271799325943, -0.15052491426467896, -0.5218683481216431, -0.4782616198062897, 0.34278228878974915, -0.8067118525505066, ...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Description - Using super in method definitions: Only functions defined as methods have access to the `super` keyword. `super.prop` looks up the property on the prototype of the object that the method was initialized on. Example: const obj = { __proto__: { prop: "f...
[ -0.13878004252910614, -0.2940547466278076, -0.8300785422325134, 0.29729247093200684, -0.23032446205615997, -1.2634778022766113, 0.2489725649356842, 1.506701111793518, 0.07791773974895477, 0.49428391456604004, -0.14553691446781158, 0.059208814054727554, 0.7650958299636841, -0.36201298236846...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Examples - Using method definitions: Example: const obj = { a: "foo", b() { return this.a; }, }; console.log(obj.b()); // "foo"
[ 0.2924257218837738, -0.20247972011566162, -1.580962896347046, 0.1645563840866089, -0.4448351562023163, -1.1487069129943848, 0.7674168348312378, 1.1889904737472534, 0.22916917502880096, -0.010357488878071308, -0.2249601185321808, 0.12013478577136993, 0.7280755043029785, -0.392206609249115, ...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Examples - Method definitions in classes: You can use the exact same syntax to define public instance methods that are available on class instances. In classes, you don't need the comma separator between methods. Example: class ClassWithPublicInstanceMethod { publicMet...
[ 0.3288056254386902, -0.06504226475954056, -0.1753343790769577, 0.8229206800460815, 0.7134366631507874, -0.25652429461479187, 0.49321258068084717, 0.8765191435813904, 0.12263983488082886, -0.5060099959373474, -0.2514425218105316, -0.0859389454126358, 0.7263740301132202, -0.6020021438598633,...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Examples - Computed property names: The method syntax also supports computed property names. Example: const bar = { foo0: function () { return 0; }, foo1() { return 1; }, ["foo".toUpperCase()]() { return 2; }, }; console.log(bar.foo0()); // 0 con...
[ 0.48292940855026245, 0.12418603897094727, -1.4912103414535522, 0.9408345222473145, 0.4280480742454529, -1.8073776960372925, 0.5537723302841187, 1.820360779762268, -0.15055201947689056, 0.04260166734457016, -0.6426888108253479, 0.7531265020370483, -0.0374261811375618, -0.5885288119316101, ...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Examples - Generator methods: Note that the asterisk (`*`) in the generator method syntax must be before the generator property name. (That is, `* g(){}` will work, but `g *(){}` will not.) Example: // Using a named property const obj = { g: function* () { let inde...
[ -0.33729007840156555, -0.22491322457790375, -1.1806381940841675, 0.6667449474334717, 0.11817697435617447, -2.236726999282837, 0.16902263462543488, 1.5556702613830566, -0.07978101819753647, 0.04749070107936859, -0.3602070212364197, 0.2271718978881836, -0.43743896484375, -0.5663313865661621,...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Examples - Async methods: Example: // Using a named property const obj = { f: async function () { await somePromise; }, }; // The same object using shorthand syntax const obj2 = { async f() { await somePromise; }, };
[ 0.09473544359207153, 0.22705797851085663, -1.4593690633773804, 0.49339112639427185, -0.3930482566356659, -0.884141743183136, 0.8457686901092529, 1.643602967262268, 0.147683247923851, 0.2675836682319641, -0.9926302433013916, 0.027484338730573654, -0.2726382613182068, -0.4087388515472412, ...
javascript/reference/functions/method_definitions/index.md
JavaScript - Functions - Method definitions - Examples - Async generator methods: Example: // Using a named property const obj = { f: async function* () { yield 1; yield 2; yield 3; }, }; // The same object using shorthand syntax const obj2 = { async *f() { yield 1; yield 2; yield 3; ...
[ -0.10829351097345352, 0.3565998077392578, -1.485730528831482, 0.43770357966423035, -0.4812081754207611, -1.0260435342788696, 0.23314201831817627, 1.974516749382019, 0.2549937665462494, 0.23946534097194672, -1.3835476636886597, 0.13333174586296082, -0.8890396952629089, -0.19616283476352692,...
javascript/reference/functions/arrow_functions/index.md
JavaScript - Functions - Arrow functions: An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate limitations in usage: - Arrow functions don't have their own `bindings` to `this`, `arguments`, or `super`, and should not be used as meth...
[ -0.017410868778824806, -0.17796851694583893, -1.2925453186035156, 0.6099374890327454, 0.04702349007129669, -2.1275687217712402, -0.37016695737838745, 1.445749282836914, 0.02859383448958397, -0.16613127291202545, 0.1206447035074234, -0.4214642643928528, -0.28813719749450684, 0.0869366824626...
javascript/reference/functions/arrow_functions/index.md
JavaScript - Functions - Arrow functions - Syntax: Example: () => expression param => expression (param) => expression (param1, paramN) => expression () => { statements } param => { statements } (param1, paramN) => { statements } Rest parameters, default parameters, and destructuring within params are su...
[ 0.8660280704498291, 0.36375856399536133, -1.1073038578033447, -0.1477808803319931, -0.7137724161148071, -1.5869718790054321, 1.3504743576049805, 1.6229612827301025, 0.41754356026649475, 0.181611105799675, -0.23559661209583282, -0.2343544065952301, -0.7233336567878723, 0.02788550779223442, ...
javascript/reference/functions/arrow_functions/index.md
JavaScript - Functions - Arrow functions - Description: Let's decompose a traditional anonymous function down to the simplest arrow function step-by-step. Each step along the way is a valid arrow function. Note: Traditional function expressions and arrow functions have more differences than their syntax. We will intr...
[ -0.009982626885175705, 0.45655643939971924, -1.2760759592056274, 0.4833235740661621, 0.2772485017776489, -1.7848100662231445, 1.6864310503005981, 0.12929043173789978, 0.012344680726528168, 0.030091924592852592, -0.8601231575012207, -0.5383460521697998, -0.6844324469566345, 0.01341641694307...
javascript/reference/functions/arrow_functions/index.md
JavaScript - Functions - Arrow functions - Description - Function body: Arrow functions can have either an expression body or the usual block body. In an expression body, only a single expression is specified, which becomes the implicit return value. The block body is analogous to traditional function bodies, where r...
[ 0.48145759105682373, 0.14582955837249756, -1.2138663530349731, 1.1453064680099487, 0.02706301026046276, -1.2861689329147339, 0.7698249816894531, 0.527500331401825, -0.8680276274681091, -0.4691517949104309, -0.01583079621195793, -0.35759255290031433, -0.4518163502216339, 0.4430539011955261,...
javascript/reference/functions/arrow_functions/index.md
JavaScript - Functions - Arrow functions - Description - Cannot be used as methods: Arrow function expressions should only be used for non-method functions because they do not have their own `this`. Let's see what happens when we try to use them as methods: Example: "use strict"; const obj = { i: 10, b: () => c...
[ 0.5063655376434326, 0.0034223406109958887, -1.3947134017944336, 0.48945656418800354, 0.462714284658432, -0.49679556488990784, 0.33003851771354675, 0.1563069373369217, -0.35985586047172546, -0.36231663823127747, -0.07399867475032806, 0.09132721275091171, -0.07684357464313507, 0.464528828859...
javascript/reference/functions/arrow_functions/index.md
JavaScript - Functions - Arrow functions - Description - No binding of arguments: Arrow functions do not have their own `arguments` object. Thus, in this example, `arguments` is a reference to the arguments of the enclosing scope: Example: function foo(n) { const f = () => arguments[0] + n; // foo's implicit argum...
[ 0.025858592242002487, -0.34721359610557556, -0.8277350664138794, 0.3752719759941101, -0.32682734727859497, -1.4967304468154907, 1.4757710695266724, 0.15778736770153046, 0.00934780016541481, -0.3592427670955658, -0.33089685440063477, -0.22225862741470337, -0.2983362376689911, 0.279272556304...
javascript/reference/functions/arrow_functions/index.md
JavaScript - Functions - Arrow functions - Description - Cannot be used as constructors: Arrow functions cannot be used as constructors and will throw an error when called with `new`. They also do not have a `prototype` property. Example: const Foo = () => {}; const foo = new Foo(); // TypeError: Foo is not a constr...
[ 0.3490672707557678, -0.20111481845378876, -1.2332267761230469, 0.7248917818069458, -0.37558066844940186, -1.4012402296066284, 0.11838287115097046, 1.654113531112671, -0.154526486992836, -0.039935216307640076, 0.2875407934188843, -1.084439754486084, 0.1728304624557495, -0.6001360416412354, ...
javascript/reference/functions/arrow_functions/index.md
JavaScript - Functions - Arrow functions - Description - Cannot be used as generators: The `yield` keyword cannot be used in an arrow function's body (except when used within generator functions further nested within the arrow function). As a consequence, arrow functions cannot be used as generators.
[ -0.22577276825904846, 0.3491900563240051, -1.6000075340270996, 0.33634501695632935, -0.9945634603500366, -1.8635921478271484, -0.29177039861679077, 2.0284385681152344, -0.38407567143440247, -0.48706427216529846, -0.24113939702510834, -0.8921088576316833, -0.8682061433792114, -0.02820062451...