Get all property name from an object - Javascript Object

Javascript examples for Object:Object Property

Description

Get all property name from an object

Demo Code

ResultView the demo in separate window

<html lang="en">
   <head></head>
   <body translate="no"> 
      <p id="test"></p>
      <p> 
         <script>
      var variableList = {};/*www  .j  a  va2 s .c  o m*/
variableList.var1 = 1;
variableList.var2 = -50;
variableList.var3 = [2,4];
variableList.var4 = "4";
variableList.var5 = 5.5;

var ele = document.getElementById("test");

for(var propertyName in variableList) {
   ele.innerHTML = ele.innerHTML + "<br>" + propertyName + " : " + variableList[propertyName];
}
    
         </script>  
      </p>
   </body>
</html>

Related Tutorials