开发者

Looping over object values works as intended, but first value is undefined?

开发者 https://www.devze.com 2023-01-19 15:10 出处:网络
Could someone explain to me why objectInfo method on the t开发者_如何学JAVAhird button returns undefined for the first value? http://jsfiddle.net/PnSSX/11/

Could someone explain to me why objectInfo method on the t开发者_如何学JAVAhird button returns undefined for the first value? http://jsfiddle.net/PnSSX/11/

I can't figure out where this comes from, because there is no property before name...

Can you help? Am I missing something?

Best regards, shapeshifta


It's because loop is initially undefined and you're calling += so it gets a converted to a string, to fix it, change this:

var loop;

To this:

var loop = "";

You can see the updated/working version here.

0

精彩评论

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

关注公众号