Object does not support attributes of properties or methods'

I work with FormData, while my code works well in Chrome, Microsoft Edge spits out the following error message Object doesn't support property or method 'entries'- which corresponds to the following code:

for(let pair of formData.entries()) {
  ...
}

I tried replacing .entries()with .getAll(), however, Microsoft Edge does not recognize either of both methods.

Is there any way to get this functionality (iterate over files FormData) from Microsoft Edge?

Microsoft Edge Console Dump for FormData strong>

enter image description here

+4
source share
2 answers

, polyfill - , , /.

Object.entries, : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill

, :

if (!Object.entries)
  Object.entries = function( obj ){
    var ownProps = Object.keys( obj ),
        i = ownProps.length,
        resArray = new Array(i); // preallocate the Array
    while (i--)
      resArray[i] = [ownProps[i], obj[ownProps[i]]];

    return resArray;
  };

, , , - Object.entries . , , , ... , , .

- angular -cli, polyfills.ts( ), , , .

+2

Angular, polyfills.ts

import 'core-js/es7/object';

Object,

enter image description here

0

Source: https://habr.com/ru/post/1670782/


All Articles