Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object.assign workaround in IE

I'm using ES6 in the following code in the angular app. Object.assign works as expected anywhere but IE.

const resetSuppItem = (item) => {
      Object.assign(vm.suppitem, _.pick($scope.item, ['item1', 'item2', 'item3']));     
    }

What could be the workaround so it works in IE?

like image 307
Nima Avatar asked Feb 12 '26 18:02

Nima


1 Answers

One workaround is to use jQuery method extend(), which is pretty simple and works in both IE and Chrome:

var user = {Name: 'Marshall', Surname: 'Depp'};
var newUserObj = $.extend({}, user);
    
newUserObj.Country = 'USA';
newUserObj.Mobile= 'xxxxxxxxxx';

console.log(user);
console.log(newUserObj);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
like image 51
Bhawesh Verma Avatar answered Feb 15 '26 07:02

Bhawesh Verma