Value was evaluated just now with console.log on JavaScript object

When I print object in HTML using for each loop I'm getting only half contents of the object but when I print using console.log and press that little triangle I'm getting full object and i is shown near that object when I hover that it says value was evaluated just now as shown in below image, enter image description here

When I print same object in HTML it looks like this,

7.33--Some Name
7.08--Some Name
7.83--Some Name

Actually, object contains a total of 5 elements as shown in the above image, Code for printing object HTML,

for (var key in obj){
    $("p").append(key+"--"+obj[key][0]+"<br>");
}

Answers:

Answer

Examining objects via console.log happens in an asynchronous manner.

The reference to the object is passed synchronously to console but it doesn't display the properties till its expanded . If the object has been modified before examining it in the console, the data shown will have the updated values. Chrome console shows a little i in a box which which says value below was evaluated just now

In order to print the object completely in console, you can stringify and log it like

console.log(JSON.stringify(obj));

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.