Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. console.clear()
  2.  
  3. const freeze = false;
  4.  
  5. var state = {
  6. name: 'joe',
  7. profile: {
  8. hobby: 'hobby 1',
  9. age: 11,
  10. address: {
  11. street: 'street 1',
  12. city: 'city 1'
  13. }
  14. }
  15. }
  16. d('1', state)
  17.  
  18. if (freeze) {
  19. Object.freeze(state)
  20. Object.freeze(state.profile)
  21. Object.freeze(state.profile.address)
  22. }
  23.  
  24. state.newProp = 'new-prop'
  25. state.name = 'name 2'
  26. state.profile.hobby = 'hobby 2'
  27. state.profile.age = 22
  28. state.profile.sex = 'm'
  29.  
  30. state.profile.address.city = 'city 2'
  31. state.profile.address.street = 'street 2'
  32. d('2', state)
  33.  
  34. function d(msg, state) {
  35. console.log('----------')
  36. console.info(msg, state)
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement