GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add indexed `Array.prototype` properties to primordial exclusions · nodejs/node@4c1fd1a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/contributing
    • primordials.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/contributing/primordials.md‎

Copy file name to clipboardExpand all lines: doc/contributing/primordials.md
+29-1Lines changed: 29 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ There are some built-in functions that accept a variable number of arguments
105105
the list of arguments as an array. You can use primordial function with the
106106
suffix `Apply` (e.g.: `MathMaxApply`, `ArrayPrototypePushApply`) to do that.
107107

108-
## Primordials with known performance issues
108+
## Limitations and exclusions
109+
110+
### Primordials with known performance issues
109111

110112
One of the reasons why the current Node.js API is not completely tamper-proof is
111113
performance: sometimes the use of primordials can cause performance regressions
@@ -137,6 +139,32 @@ performance of code in Node.js.
137139
In general, when sending or reviewing a PR that makes changes in a hot code
138140
path, use extra caution and run extensive benchmarks.
139141

142+
### User-defined index properties on `Array.prototype`
143+
144+
A recurring theme in issues/PRs is that changing the behavior of indexed
145+
array properties via `Array.prototype` breaks a particular Node.js API.
146+
147+
<!-- eslint-disable accessor-pairs -->
148+
149+
```js
150+
// User-land
151+
Object.defineProperty(
152+
Array.prototype,
153+
'0',
154+
{ set() {} },
155+
);
156+
157+
// Core
158+
const array = [];
159+
ArrayPrototypePush(array, 'some value');
160+
console.log(array[0]); // undefined
161+
```
162+
163+
These patterns are expected to break both ECMAScript builtins and application
164+
code, and Node.js does not make any attempt to harden against them. To do so
165+
would necessitate using property descriptor methods for every single array
166+
interaction, which is not practical.
167+
140168
## Implicit use of user-mutable methods
141169

142170
### Unsafe array iteration

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.