{"version":"1.0","type":"rich","title":"How good your JS?","description":"This example demonstrates a common JavaScript closure pitfall inside a loop. The code defines an `addLinks` function that creates five anchor elements, each intended to alert its index when clicked. However, because the loop variable `i` is captured by reference in the click handler, every link alerts the final value, 5, instead of its own index. The visualization relies on the browser’s DOM API, including `document.createElement` and `element.onclick`, with the result shown when `window.onload` triggers the function. It highlights the difference between expected and actual behavior in event handling.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-668313573c68335def8de62481d750ef?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}