I am reading RSS feed and pushing both Title and Link into an Array in Jquery.
What i did is
var arr = [];
This code
var title = news.title;
var link = news.link;
arr.push({title : link});
is not doing what you think it does. What gets pushed is a new object with a single member named "title" and with link
as the value ... the actual title
value is not used.
To save an object with two fields you have to do something like
arr.push({title:title, link:link});
or with recent Javascript advances you can use the shortcut
arr.push({title, link}); // Note: comma "," and not colon ":"
The closest thing to a python tuple would instead be
arr.push([title, link]);
Once you have your objects or arrays in the arr
array you can get the values either as value.title
and value.link
or, in case of the pushed array version, as value[0]
, value[1]
.