Skip to content

Instantly share code, notes, and snippets.

@saurookadook
Created April 16, 2025 15:15
Show Gist options
  • Select an option

  • Save saurookadook/89547fdaf69e8bbd3266e05f012e3d62 to your computer and use it in GitHub Desktop.

Select an option

Save saurookadook/89547fdaf69e8bbd3266e05f012e3d62 to your computer and use it in GitHub Desktop.
function logAttrs({ displayName, obj }) {
console.group(displayName);
for (const [key, value] of Object.entries(obj)) {
console.log(`${key}: ${value}`);
}
console.groupEnd();
}
(function() {
const commonArgs = {
bodyId: 'modalBody',
headingId: 'modalHeading',
id: 'modal',
nested: []
};
const StoryOne = {
displayName: 'StoryOne',
args: {
...commonArgs
}
}
const StoryTwo = {
displayName: 'StoryTwo',
args: {
...commonArgs
}
}
logAttrs({ displayName: 'commonArgs', obj: commonArgs });
logAttrs({ displayName: StoryOne.displayName, obj: StoryOne.args });
logAttrs({ displayName: StoryTwo.displayName, obj: StoryTwo.args });
StoryOne.args.bodyId = 'MEOW';
StoryOne.args.headingId = 'WOOF'
StoryOne.args.nested.push(4)
StoryTwo.args.id = 'hehehehehe'
StoryTwo.args.nested.push(2)
logAttrs({ displayName: 'commonArgs', obj: commonArgs });
logAttrs({ displayName: StoryOne.displayName, obj: StoryOne.args });
logAttrs({ displayName: StoryTwo.displayName, obj: StoryTwo.args });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment