JSFiddle - React, Tailwind, and code Playground JavaScript var obj = {a:0,b:0}, i=0; for (var k in obj) { obj[i++] = 0; } alert(i) // 2