In my mind I want to push a key-value on array.
Say for example in PHP this is done like this:
$err = array();
function check($k,$v) {
$err[$k] = $v;
}
How is this done exactly in JavaScript/jQuery?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Javascript key/value pair support in Object, not in Array
Insert Element:
Check that a key exists:
According to your function:
More on insert:
Get value:
Count length:
If you want to get length of an array you have to use
.length.For example:
And if you want to count the length of an Object:
To Delete item:
if you want to remove an item from an Object:
to delete an item from an array:
also to remove array element you can do