Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

JavaScript: Get Key and Value from Object

I can get the key from an object.  How can I also get the value?
var data = {"One":1,"Two":2, "Three":3};
for (var key in data) {
 alert('Key:' + key + '\nValue:' + '???' )
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of s_chilkury
s_chilkury
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hankknight

ASKER

Thanks.
for (var key in data) {
        if (data.hasOwnProperty(key)) {
            alert('Key:' + key + '\nValue:' + data[key] );
        }
}

Open in new window