JavaScript modules and data
Modules let one source file expose values to another. In a Next.js app, keeping a catalog in a separate module can make the page easier to understand and test. An exported array is ordinary JavaScript data; importing it does not create an HTTP route.
Select book titles without changing the catalog
const books = [{ title: "Moss", price: 12 }, { title: "Harbor", price: 18 }];const titles = books.map(book => book.title);console.log(titles.join(", "));Expected console text: Moss, Harbor. map constructs an array of the returned values. It does not replace the original book objects here. The callback returns title strings. If it returns the original objects instead, both arrays refer to the same objects; map does not deep-clone them. A callback that assigns to book.price would still mutate the source object.
Separating data and presentation
For a project, place export const books = [...] in a module such as app/catalog-data.ts, then import it in the page using import { books } from "./catalog-data". The relative path starts from the importing file. Named exports use braces in the import; a default export does not. A page may render the array with JSX once you know component composition.
Common mistake
Do not call an exported data array a database. In-memory fixtures are useful for deterministic lessons but do not provide durable storage.
Try it yourself
Given three books with prices, use filter to select the ones under 15 and return their titles.
Example status: pure JavaScript sample checked locally; no ByteMind evaluator or Next.js build was tested.