komal salvi
komal salvi

Reputation: 33

Retrieve value from an Object which is a key in a hashmap

I have a DWR call which returns a MAP<Employee, Double>. Employee is a class having attributes, employeeId and employeeName.

In my javascript, I m doing something like this.

for (var k in employees) {
    if (employees.hasOwnProperty(k)) {                  
        alert("EmployeeId : " + k.employeeId);
    }
}

It shows me undefined.

Upvotes: 0

Views: 109

Answers (1)

Joseph
Joseph

Reputation: 119847

key? the k is the key. maybe you meant access the value of the key:

var employee = employees[k]

if employees[k] contains an object with the employeeId, then:

for (var k in employees) {
    if (employees.hasOwnProperty(k)) {                   
        alert("EmployeeId : " + employees[k].employeeId);
    }
}

Upvotes: 1

Related Questions