Happy April Fool’s Day! No, I don’t have a prank for you.
I find myself returning to my journal, but I struggle to find much to write about. It’s pretty windy today, and there’s a severe weather warning in effect because of it. If it weren’t for the wind, it would be a lovely day outside. Earlier, it even rained for a short while. This morning, I had my blood work done. The process was fairly quick once I got in. There were many people ahead of me at Tricore. I had to fast beforehand, and I’m still waiting to eat until lunch.
I just finished preparing some teriyaki sauce using a straightforward recipe, and it turned out quite well. Karissa is tidying up, while Alex is asleep since he needs to work tonight. Meanwhile, I’m still researching the function I need to develop. My goal is to create a deep copy of a nested object without using JSON.stringify().
A deep clone of an object involves creating a new object that precisely replicates the original, including all nested objects and arrays, without retaining any references to the original. This guarantees that changes made to the clone do not impact the original object. Here’s what I have so far:
function deepClone(obj) { if (obj === null || typeof obj !== 'object') { return obj; // Return the value if it's not an object } }
obj === null
- In JavaScript, typeof null is “object”
- However, null is not an actual object that we need to deep clone.
- Since null is a primitive value, it should be returned as is.
typeof obj !== ‘object’
- typeof obj checks what kind of data type obj is.
- If obj is not an object, it must be a primitive value (like a number, string, boolean, undefined, etc.).
- Since primitive values are immutable, they can be returned directly.
Without this check, we would unnecessarily try to loop over primitive values or cause errors. This prevents recursion from going too deep into values that don’t need cloning.
I received an email and a text about my therapy appointment scheduled for tomorrow, which completely slipped my mind. I don’t even recall it being arranged, and it wasn’t on my calendar. Well, it is there now! I thought I didn’t have therapy this week, but it turns out I do after all.
Tonight, Tommy and I are planning to do some weight training. The wind outside is quite strong, so we might need to prepare dinner indoors instead of using the griddle outside. I asked Tommy to decide if he thinks we should cook inside this evening.





