mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 08:35:07 +08:00
Represent ordinary JavaScript arrays with hole, value, and explicit-undefined states; add sparse side storage and carry missing values through the frontend, native backends, runtime, and Node-facing consumers.
11 lines
481 B
TypeScript
11 lines
481 B
TypeScript
// Optional values carried through locals and function returns still occupy the UNDEFINED state.
|
|
const source: number[] = [12];
|
|
const missing = source[8];
|
|
function maybe(values: number[]): number {
|
|
return values[8];
|
|
}
|
|
const localLiteral = [missing, source[0]];
|
|
const returnedLiteral = [maybe(source), source[0]];
|
|
console.log("local", localLiteral.length, localLiteral[0], localLiteral[1]);
|
|
console.log("returned", returnedLiteral.length, returnedLiteral[0], returnedLiteral[1]);
|