JavaScript functions can create, read, update, and delete properties on ordinary objects. These operations change data in memory; they do not, by themselves, save a record to a database or send a request to a server.
What CRUD means for a JavaScript object
An object associates property keys with values. A function stored on an object is commonly called a method, but CRUD helpers can also be ordinary functions that receive an object as an argument. Here, CRUD means creating, reading, updating, and deleting that object’s properties.
As an Amazon Associate I earn from qualifying purchases.
The examples below use a record object and core JavaScript syntax. Bracket notation lets a helper use a property key supplied at runtime; dot notation is convenient when the key is fixed and identifier-like.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
A small set of CRUD functions
function createRecord(id, value) {
return { id, value };
}
function readProperty(record, key) {
return Object.hasOwn(record, key) ? record[key] : undefined;
}
function updateProperty(record, key, value) {
record[key] = value;
return record;
}
function deleteProperty(record, key) {
return delete record[key];
}
const record = createRecord("task-1", "Draft");
readProperty(record, "value");
updateProperty(record, "value", "Published");
deleteProperty(record, "value");
createRecord returns a new object. readProperty checks for an own property before reading it. updateProperty changes the object passed to it, and deleteProperty returns the result of the delete operator.
#1 Best Overall
How to create a property
Create a new object
An object literal is a direct way to create a record-like object: const user = { name: "Mina" };. A function such as createRecord can return a new literal whenever a caller needs a new record.
Add a property to an existing object
Assignment can add a property: user.email = "[email protected]";. Use dot notation for a known identifier-like key. If the key is held in a variable, use brackets: const key = "email"; user[key] = "[email protected]";. Writing user.key would access the literal property named key, not the value stored in the variable.
Rank #2
Assignment to a key that already exists replaces its value. If an operation must create only when a key is absent, it needs an explicit existence check and a defined response for conflicts.
How to read a property safely
For a fixed key, use record.value; for a computed key, use record[key]. Reading a missing property yields undefined. That result alone cannot tell you whether the property is absent or present with the value undefined.
Object.hasOwn(record, key) checks whether the property belongs directly to the object. This matters when a CRUD helper should operate on the object’s own data rather than values available through its prototype chain. The in operator is not interchangeable: it also reports inherited properties. See MDN’s guide to working with objects.
How updates affect the caller’s object
JavaScript passes an object argument by sharing the object value. Assigning record[key] = value through the parameter changes that same object, so other references to it can observe the change. A helper may return the object for convenient chaining or inspection, as updateProperty does, but the mutation is visible even if the helper returns nothing.
Rank #4
Reassigning the parameter itself is different: function replace(record) { record = {}; } changes only the local parameter binding. It does not make the caller’s variable refer to a new object. For function and parameter behavior, see MDN’s JavaScript functions guide.
Free tools Windows power users keep installed
One-click scans. No signup required.
Mutate or return a copy?
The example deliberately mutates the passed object. If a caller instead needs a separate shallow object, object spread or Object.assign can make a copy before changing it. A shallow copy has a different identity, while nested objects may still be shared. These approaches therefore have different effects on references; choose according to whether the caller expects the original object to change. MDN documents these object APIs in its Object reference.
Best Value
Assignments can be constrained
Assignment does not guarantee a successful change in every case. A property may be non-writable, an object may be frozen or non-extensible, or an accessor may define custom behavior. Property descriptors govern attributes such as writability and configurability; consult the MDN Object reference when designing helpers that must handle such objects.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.What delete does—and does not do
delete record[key] attempts to remove an own property. It returns true when deletion succeeds or when the property was absent; it returns false when a non-configurable property cannot be removed in non-strict code. In strict mode, attempting to delete a non-configurable property throws a TypeError.
If an object has an own property that shadows an inherited property, deleting the own property reveals the inherited value; it does not remove the prototype’s property. Deleting a property also is not a direct instruction to free memory. It removes a property reference, while memory management is handled separately. For the operator’s behavior and restrictions, see MDN’s delete reference.
Recommended Free Tools
In-memory CRUD is not database or API CRUD
Creating or deleting a JavaScript object property changes data in the running program. These language operations do not persist a record after a page or process ends, synchronize changes with a server, or provide database transaction behavior. Saving data or changing a server-side record requires a separate storage or API layer with its own contract.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




