代码语言:javascript复制
var key = "accountBingFlag1";var value = obj[key];
var key = "accountBingFlag1";var value = eval("obj." key);
实例
代码语言:javascript复制<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
<script>
var bindingMessageVo={accountBingFlag1:"100",accountBingFlag2:"200",accountBingFlag3:"300"}
for (var i=1;i<4;i ){
var accountBingFlag = "accountBingFlag" [i];
console.log(accountBingFlag);
console.log(bindingMessageVo[accountBingFlag]);
console.log(eval("bindingMessageVo." accountBingFlag))
}
</script>
</html>