謝晒的PHP網頁設計
聯絡E-mail:
sean0704@gmail.com
站內搜尋
Sunday, July 26, 2015
[JavaScript] Object 使用變數當 key 取值
var obj = {
"USD": 30.1,
"JPY": 0.27
};
//一般取值的方法為 obj["USD"]
//以變數當 key 的方法如下:
var curr = "USD";
alert(obj[curr]); //會跳出 30.1
No comments:
Post a Comment
Newer Post
Older Post
Home
View mobile version
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment