This is probably trivial, but i couldn't find an answer.
I have this object:
obj = {
key1 : {val : "hi", val2 : "pizza"},
key2 : {val : "hello", val2 : "cheese"},
key3 : {val : "wazzup", val2 : "hamburger"}
};
And this function:
function foo () {
$.each(obj, function(key, value) {
console.log(value.val2);
});
}
foo();
This works quite fine.
Question: how can I access one specific property passing it as an argument? For example:
function foo (arg) {
$.each(obj, function(key, value) {
console.log(value.arg);
});
}
foo(val2);