I can’t seem to figure out how to get the following results…
var errors;
errors = { username: "username_error", email: "email_error" };
…when looping through data in this code:
var errors = {}
$.each(data,function(k,v)
{
errors[k] = v; // doesn't seem to work
});
It does produce an object yet in a different format.
EDIT: console log.
Expected results:
Object
email: "email_error"
username: "username_error"
__proto__: Object
edit:25
Object
__proto__: Object
Generated results:
Object
email: Array[1]
0: "email_error"
length: 1
__proto__: Array[0]
username: Array[1]
0: "username_error"
length: 1
__proto__: Array[0]
__proto__: Object
By the results you posted with the log output, it seems the objects in
dataare arrays. Try replacing the assignment with this: