Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
If the new and old nodes are of different types. This could be either of the cases below:
one of the node is a TextNode while the other one is an ElementNode
Both are ElementNode but with different tag.
In fact, all my base cases are defined in a guard clause. This means that all the return statement before the last return can be considered as base case.
Hey! I'm YCMJason, a Software Engineer in London 👨💻. Love diving into tech puzzles and sharing them! 🧩
All views expressed here are my own opinions, so please take them with a pinch of salt! 🧂
Oops, I just realised there is one more, which is when there is no children in the node. But I didn't explicitly deal with that case as it will be automatically dealt with in the for loop in diffChildren
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I am sorry that my explanation didn't help. :(
diff
has two base cases:undefined
In fact, all my base cases are defined in a guard clause. This means that all the return statement before the last return can be considered as base case.
Oops, I just realised there is one more, which is when there is no children in the node. But I didn't explicitly deal with that case as it will be automatically dealt with in the for loop in
diffChildren