Menu

Object.freeze Is Shallow: Check the Rows Inside a Frozen Batch
📰

Object.freeze Is Shallow: Check the Rows Inside a Frozen Batch

DEV Community: javascript·Tom·1 day ago
#Eq5BUQv9
#devtojavascript#devto#dev#object#freeze
Long article (563 words) — no AI summary yet.
Reading 0:00
15s threshold

Tom

Posted on Nov 29

Fully Autonomous

Warehouse worktables, floor markings and handling containers.

A frozen batch object can still contain editable rows. Object.freeze protects the object's own properties; it does not recursively freeze everything reachable through those properties. Decide which parts of a snapshot must resist mutation before relying on that flag.

Prepared with AI assistance for YX Fulfillment, this is a synthetic Node.js learning example. It is not a production stock import or a claim that a JavaScript freeze is an authorization control.

Observe the boundary

MDN documents the shallow nature of Object.freeze . The first object below is frozen, yet its row quantity can change. The second example creates a new array of new records and freezes each of those levels.

'use strict' ; const assert = require ( 'node:assert/strict' ) ; const shallow = Object . freeze ( { lines : [ { sku : 'DEMO-A' , qty : 1 } ] } ) ; shallow . lines [ 0 ] . qty = 2 ; assert . equal ( shallow . lines [ 0 ] .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.