Friday, September 2, 2016

note to self: lodash assign();

It wasn't clear to me what the advantage of
_.assign($rootScope.creative, { somejson: ‘map'} );
was vs
$rootScope.creative = { somejson: ‘map’};

What's going on in the first case is actually a merge; useful if $rootScope.creative already existed with some keys, somejson would be a new key in it. (or any old value of somejson would be replaced with 'map')

Learn something new every day! Some days, two things!

No comments:

Post a Comment