Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let oldProps = null;
- function shallowCompare (props){
- if(props !== oldProps) console.log(props);
- }
- const john = { name: "john", age: 30 };
- shallowCompare(john) // prints -> { name: "john", age: 30 }
- const johnClone = {...john};
- johnClone.age=31;
- shallowCompare(johnClone) // prints -> { name: "john", age: 31 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement