Answer the question
In order to leave comments, you need to log in
How to put a value from another array into the key name of an associative array?
I have a script that dynamically adds the received values to an associative array, the array itself looks something like this:
var object = {
_id: chatMsg['user_id'],
chatlog: {
msg: {
attachments: chatMsg['attachments'],
date: chatMsg['date'],
msg_id: chatMsg['message_id']
}
}
}
var object = {
_id: chatMsg['user_id'],
chatlog: {
chatMsg['message_id']: {
attachments: chatMsg['attachments'],
date: chatMsg['date']
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question