Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object doesn't support property or method 'values' [duplicate]

I am trying to write some codes to get json file and read. But this codes works in chrome, doesn't works in IE11 and I need to use IE, What is the real solution for solve this problem actually. I changed some value names but same problem still seems.

Error Message

<html xmlns="http://www.w3.org/1999/xhtml">
    <head> 
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>   
    	<table id="userdata" border="0.02">
    		
    			<th>Revision  Date</th>
    			<th>Document  Name</th>
    			<th>Department </th>
    			<th>Description</th>
    			<th>Link</th>
    	</table>
    <script>
              myObjects = [];
            $.getJSON('https://api.myjson.com/bins/1djve3', function(deneme) {
            myObjects = Object.values(deneme);
            console.log("Objects in array " + myObjects.length);
            
             $.each(myObjects, function(i, person) {
                  $('#userdata  th:nth-child(2)').html(person.revisiondate)
                  console.log("Person-" + person.revisiondate);
                  console.log("Person-" + person.documentname);
                  console.log("Person-" + person.department);
                  console.log("Person-" + person.description);
                  console.log("Person-" + person.link.split('href=')[1]+"' "+person.link.split('href=')[1]);    
                  
                  var $row = 
    							"<tr><td>" + person.revisiondate + 
                                "</td><td>" + person.documentname + 
                                "</td><td>" + person.department +
                                "</td><td>" + person.description + 
                                "</td><td><a target='_blank' href='"+ person.link.split('href=')[1]+"' >"+person.link.split('href=')[1]+"</a></td></tr>"  
    
    $('table> tbody:last').append($row);
                }); 
              }); 
    		  
           
    </script>
    </body>
    </html> 
like image 282
MCoskun60 Avatar asked Apr 06 '17 12:04

MCoskun60


People also ask

What does object assign() do?

The Object.assign() method copies all enumerable own properties from one or more source objects to a target object. It returns the modified target object.

Does object assign Overwrite?

Object. assign() returns a target object. In case of a name collision between a source and target property, Object. assign() will overwrite the local property of the target object.

How to copy a js object?

var clone = Object. assign({}, obj); The Object. assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object.


1 Answers

Instead of this line,

myObjects = Object.values(deneme);

write,

myObjects = Object.keys(deneme).map(itm => deneme[itm]);

Because, Object.values is an experimental feature and it is not being supported in IE.

If your browser doesn't supports arrow functions too then write,

myObjects = Object.keys(deneme).map(function(itm) { return deneme[itm]; });
like image 50
Rajaprabhu Aravindasamy Avatar answered Oct 19 '22 14:10

Rajaprabhu Aravindasamy