hasOwnProperty seems to be the popular solution, but it's worth pointing out that it only deals in strings and can be expensive to call.
If you're using objects as keys in your Dictionary hasOwnProperty will not work.
The more reliable and performant solution is to use strict equality to check for undefined.
function exists(key:*):Boolean {
return dictionary[key] !== undefined;
}
Remember to use strict equality otherwise entries with a null value but valid key will look empty i.e.
null == undefined // true
null === undefined // false
And actually, as has been mentioned using in
should work fine too
function exists(key:*):Boolean {
return key in dictionary;
}