// using indexer
var name = dict["FirstName"];
// as property
var name = dict.FirstName;
var dict = {};
var f = function() {
// do something
};
// setup Function as Value
dict['method'] = f;
// setup Function as Key
dict[f] = 'some value';
// execute Function from Value
dict['method']();
var method = dict.method;
method();
// get value for Key
var val = dict[f];
JavaScript, 字典, 键值对, 函数, 属性
学习如何在JavaScript中创建和使用字典,包括设置和获取键值对,以及如何将函数作为值和键使用。