Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. let oldProps = null;
  2. function shallowCompare (props){
  3. if(props !== oldProps) console.log(props);
  4. }
  5.  
  6. const john = { name: "john", age: 30 };
  7.  
  8. shallowCompare(john) // prints -> { name: "john", age: 30 }
  9.  
  10. const johnClone = {...john};
  11. johnClone.age=31;
  12. shallowCompare(johnClone) // prints -> { name: "john", age: 31 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement