Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Records and aggregates

A record groups named fields describing one thing, while an aggregate combines multiple values. JavaScript can model these structures with ordinary objects and arrays, with important consequences for mutation and object identity.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

const record = { field: value };
const aggregate = [record];
record.field;
record["field"];
aggregate[0];

In data modelling, a record is a set of named fields, such as a student's name and scores. Aggregate is a broader term for a structure combining multiple values; a record is one such model. These are not separate JavaScript keywords or type declarations: an ordinary object { name: "Ada", scores: [8, 10] } serves as a record, while an array stores ordered elements.

Read properties with student.name or student["name"], and an array element with student.scores[0]. Array indices start at zero. Objects and arrays can contain further objects and arrays, forming nested aggregates.

Assigning const alias = student does not copy the object: both variables refer to the same object. A change through alias is therefore visible through student. const prevents reassignment of the variable but does not freeze the object's contents. The === operator compares object identity, not whether their fields match.

Do not confuse this model with the Record specification type used in ECMAScript algorithms. That is a specification-description tool, not a value type directly available in application code. The example uses standard ECMAScript 2015 syntax (const) and needs no browser API beyond the console supplied by the environment.

Examples

const student = { name: "Ada", scores: [8, 10] };
const alias = student;
alias.scores[0] = 9;
const sameFields = { name: "Ada", scores: [9, 10] };
console.log(student.name);
console.log(student.scores[0] + student.scores[1]);
console.log(student === alias);
console.log(student === sameFields);

Result

Ada
19
true
false

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources