Hacker News new | past | comments | ask | show | jobs | submit login

Any popular "deep freeze" utilities around?



    function deepFreeze(obj) {
      const out = Object.freeze(obj);
      Object.keys(out).forEach(key => {
        if (typeof out[key] === 'object') {
          out[key] = Object.freeze(out[key]);
        }
      });
      return out;
    }


I think you meant "out[ key ] = deepFreeze( out[ key ] )" in the innermost step :-)

(recursive)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: