Skip to content

Commit

Permalink
Grammar changes in sparse-arrays.md
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari committed Nov 14, 2016
1 parent 565b811 commit 01cd8d9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions v8-tips/sparse-arrays.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Sparse Arrays

Internally V8 can represent `Array` following two approach:
Internally, the V8 engine can represent `Array`s following one of two approaches:

- **Fast Elements**: linear storage for compact keys sets.
- **Dictionary Elements**: hash table storage otherwise (more expensive to access on runtime).
- **Dictionary Elements**: hash table storage (more expensive to access on runtime).

If you want that V8 represents your `Array` in the `Fast Elements` form, you need to have a special considerations:
If you want V8 to represent your `Array` in the `Fast Elements` form, you need to take into account the following:

- Use contiguous keys starting at `0`.
- Don't pre-allocate large `Array` (e.g. *> 64K* elements) that you don't use.
- Don't delete elements, in special in numeric `Array`'s.
- Don't delete elements, specially in numeric `Array`'s.
- Don't load uninitialized or deleted elements.

Another consideration: Any name used as property name that is not a string is stringified via `.toString()`, so:
Another consideration: any name used as property name that is not a string is stringified via `.toString()`, so:

- `1` will be `'1'`.
- `undefined` will be `'undefined'`.
Expand Down

0 comments on commit 01cd8d9

Please sign in to comment.