Skip to content

Instantly share code, notes, and snippets.

View digitaldrreamer's full-sized avatar
💭
I may be slow to respond. Gimme three days, at most ;)

Abdullah Basheer digitaldrreamer

💭
I may be slow to respond. Gimme three days, at most ;)
View GitHub Profile
@digitaldrreamer
digitaldrreamer / objectDiff.js
Last active October 23, 2024 08:34
A Function to Compare Two Objects and Get The Difference or return `null`.
/**
* Compares two objects and returns the differences, or null if they're the same
* @param {Object} original - Original form data
* @param {Object} current - Current form data
* @returns {Object|null} Object containing only the changed fields, or null if no changes
*/
function getObjectDiff(original, current) {
const changes = {};
for (const [key, value] of Object.entries(current)) {