Reputation: 119
I have a JQuery which is retunring an array of LockedProjects [] which is decalred as global variable.
var LockedProjects = [];
I wanted to display the values of this array LockedProjects in another JQuery I m accesing this array of values in an alert box to display and separating them with comma. Before displaying that I am checking the length of it.
if(LockedProjects.length>0)
alert(LockedProjecrs.join(,));
'if' condition is passed But It is not displaying any values. Can any one help on this?
Upvotes: 0
Views: 33
Reputation: 68400
The default separator for join
is ,
so you could simply do
LockedProjects.join()
The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma.
Upvotes: 0
Reputation: 36784
join()
expects string, you've given it a comma. Also, 'LockedProjects' is spelt incorrectly. I believe it should be:
alert(LockedProjects.join(","));
Upvotes: 1