I have an idea of making a web-form that receives an object name and outputs all its properties. To do that I wrote a following piece of code:
var html5form = document.getElementsByClassName("html5_form");
html5form[0].onsubmit = function (e) {
var val = e.target.querySelector("input[name=obj]").value,
obj = window[val],
enumObj = new obj();
for (prop in enumObj) {
console.log(prop);
}
return false;
}
I made a datalist with object constructors and attached it to the input field. But I am actually iterating object instances, not constructors. The above mentioned code only works when I enter constructors like DataView and ArrayBuffer and doesn't work on Array, Number and so on. What's wrong with my code? I've tried to debug, but no results.