Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • JavaScript Object Properties

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 147
    Comment on it

    Properties are defined as the values that are associated with a JavaScript object.It is also called the very important part of Javascript. A JavaScript object is made up of a collection of un-ordered properties.It can be changes, added, deleted.

    syntax for using property of an object is:

    objectName.property          // person.height
    OR
    objectName["property"]       // person["height"]
    OR
    objectName[expression]       // a = "height"; person[a]
    

    Exapmle of JavaScript for in loops through the properties of an object. In this example the for in loop will execute once for each property.

    <p id="property"></p>
    
    <script>
    var txt = "";
    var name = {fname:"A123", lname:"B123", age:25}; 
    var x;
    for (x in name) {
        txt += name[x] + " ";
    }
    document.getElementById("property").innerHTML = txt;
    </script>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: