开发者

How to retrieve a JavaScript property that contains a period

开发者 https://www.devze.com 2023-04-11 01:10 出处:网络
I am using the github API to get my gists. The actual json returned from github contains a property called \'GetGists.js\', how do I get the value 开发者_JS百科of that property?

I am using the github API to get my gists. The actual json returned from github contains a property called 'GetGists.js', how do I get the value 开发者_JS百科of that property?

gistObject.files.GetGists.js returns an error

This is my example page, when you click on the link it will log the object in the console.


gistObject.files["GetGists.js"] should be used. All JavaScript properties can also be accessed through square braces.

Another example:
    window.location.href === window["location"].href == window["location"]["href"];


gistObject.files['GetGists.js']


here's the solution

gistObject.files['GetGists.js']


instead of using dot notation, use index notation:

gistObject.files["GetGists.js"]
0

精彩评论

暂无评论...
验证码 换一张
取 消