javascript - Object Uncaught SyntaxError: Unexpected number - Stack Overflow

Using:console.log("First Item Author: "+myjson.value.items.0.author);I get the following erro

Using:

console.log("First Item Author: "+myjson.value.items.0.author);

I get the following error:

Object Uncaught SyntaxError: Unexpected number 

Trying to access the following object:

Using:

console.log("First Item Author: "+myjson.value.items.0.author);

I get the following error:

Object Uncaught SyntaxError: Unexpected number 

Trying to access the following object:

Share Improve this question edited Aug 27, 2013 at 17:21 Felix Kling 818k181 gold badges1.1k silver badges1.2k bronze badges asked Aug 27, 2013 at 17:05 Hydra IOHydra IO 1,5611 gold badge13 silver badges29 bronze badges 3
  • 1 That's Javascript. It has nothing to do with jQuery. – SLaks Commented Aug 27, 2013 at 17:11
  • It has nothing to do with JSON either. – Felix Kling Commented Aug 27, 2013 at 17:21
  • possible duplicate of Access / process (nested) objects, arrays or JSON – Felix Kling Commented Aug 27, 2013 at 17:21
Add a ment  | 

2 Answers 2

Reset to default 4

0 is not a valid identifier and cannot be used as a direct property name.

Instead, use array notation:

items[0].author

0 is not a valid identifier name. Use bracket notation instead of dot notation:

console.log("First Item Author: " + myjson.value.items[0].author);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745202858a4616430.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信