如果我有一个如下所示的 JavaScript 对象:
返回结果:
var columns = {
left: true,
center : false,
right : false
}
我有一个函数,它接收对象和属性名称:
and I have a function that is passed both the object, and a property name like so
返回结果:
我有一个函数,它接收对象和属性名称:
//should return false
var side = read_prop(columns, 'right');
read_prop(object, property)
的主体会是什么样子?
prop
必须是字符串类型或解析为字符串类型。 - prasanthvundefined
。 - ThiefMasterundefined
的信息是一个好主意。询问这个问题的人很可能不知道在这种情况下会返回什么。 - Alexander Abakumov