Printing a record in Javascript -


this question has answer here:

i have record contains following.

var web = [{             url : "www.facebook.com",               content : "social media website."             },            {             url : "www.reddit.com",             content : "a vast forum different topics"             }] ; 

i trying print out url part of record doing following

for(var i=0;i<web.length;i++) {     alert({"url":web[i].url,"description":web[i].content})     } 

but getting output [object object].

any appreciated.

alert takes string, not object. can decent representation of object string json.stringify. try

alert(json.stringify({"url":web[i].url,"description":web[i].content})); 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -