最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to retrieve a JavaScript property that contains a period - Stack Overflow

programmeradmin8浏览0评论

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 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.

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 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.

Share Improve this question edited Nov 4, 2011 at 20:21 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Oct 6, 2011 at 17:51 FarFigNewtonFarFigNewton 7,27314 gold badges55 silver badges78 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 5

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)

  1. 暂无评论