I have an object:
var myObj = {
"0": "#fff",
"trace": "#0000cc",
"0.1": "#3366ff",
"0.2": "#999900",
"0.5": "#ffcc00",
"1": "#ff9900",
"2": "#ff0000",
"5": "#ff00ff",
"10": "#ccffff"
}
I need to call this object keys and create list of items with their key text on each of them:
var myKeys = Object.keys(myObj);
myKeys.forEach(function (item) {
var li = document.createElement("li");
li.appendChild(document.createTextNode(item));
});
This returns:
<li>0</li><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>10</li><li>trace</li><li>0.1</li><li>0.2</li><li>0.5</li>
How can I make this in a way that it doesn't automatically sort the object?