Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[JS] Creating element with JS arrays returns "0" instead of "undefined" for missing elements.

Open
#59 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Domain
data

Research direction

Start with the tableFromArrays example in the issue and reproduce it from the linked StackBlitz main.js entry point. Trace how the regular JavaScript array becomes the Vector and how Vector.get handles indexes beyond its length, comparing it with the Float64Array case. Done means the array-backed vector returns undefined for the same out-of-range access while preserving the reported table and vector lengths.

Written by the indexing model from the issue text.

Description

Type: bug
Describe the bug, including details regarding any error messages, version, and platform.

When creating a table using regular JavaScript Array syntax, the resulting Vector gives unexpected results:

import { tableFromArrays } from 'https://cdn.skypack.dev/apache-arrow@15.0.2';

const table = tableFromArrays({
  a: new Float64Array([100, 200, 300]),
  b: [100, 200, 300],
});

console.log('Table rows:', table.numRows);
const vectorA = table.getChild('a');
const vectorB = table.getChild('b');
console.log('Length of "a":', vectorA.length);
console.log('Length of "b":', vectorB.length);
console.log('Element "a" at index 3:', vectorA.get(3));
console.log('Element "b" at index 3:', vectorB.get(3));
console.log('Element "a" at index 100:', vectorA.get(100));
console.log('Element "b" at index 100:', vectorB.get(100));
console.log('Vector "a" internal data length:', vectorA.data[0].values.length);
console.log('Vector "b" internal data length:', vectorB.data[0].values.length);

The output is:

Table rows: 3
Length of "a": 3
Length of "b": 3
Vector "a" at index 3: undefined
Vector "b" at index 3: 0
Vector "a" at index 100: undefined
Vector "b" at index 100: undefined
Vector "a" internal data length: 3
Vector "b" internal data length: 8

I would expect "b" to also return undefined for elements outside of its length. Instead it returns zero.

I noticed that the internal length of the Float64Array is 8 instead of 3, I suspect this has something to do with it?

Here's an online playground that shows the issue:

https://stackblitz.com/edit/vitejs-vite-9k7gaz?file=main.js

Component(s)

JavaScript

Dominant language
TypeScript
Stars
112
Forks
23
Avg merge
17h 55m
Merged PRs (30d)
10

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/arrow-js

All issues in apache/arrow-js

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.