problem with array - Forum

Forum Navigation
You need to log in to create posts and topics.

problem with array

//this works
var videoSources = [//array of sources to use in the loop
["http://www.w3schools.com/html/mov_bbb.mp4"],
["http://www.w3schools.com/html/movie.mp4"]
];
//but this don't work
var videoSources=$App.files;
console.log(videoSources);
// gives this errors:
//jQuery.Deferred exception: Operando no válido para 'in': se esperaba un objeto
//Operando no válido para 'in': se esperaba un objeto (jquery.min.js, 2)

I also try:
var videoSources=[$App.files];
// no error, but don't show the videos

//the console log with videoSorces show:
//["http://www.w3schools.com/html/mov_bbb.mp4"],["http://www.w3schools.com/html/movie.mp4"]

//[files] is declared with CreateEmptyArray [files]
// and filled as:
// $App.files[0]="[\"http://www.w3schools.com/html/mov_bbb.mp4+"\"]";
// $App.files[1]="[\"http://www.w3schools.com/html/movie.mp4+"\"]";

Ok, finally works with:

str="http://www.w3schools.com/html/mov_bbb.mp4";
$App.files[i]=[str];

 

@emmanuel-fernandez try this:

var videoSources = $App.files.slice();

I asume $App.files is an Array.
The slice() operation clones the array and returns a reference to a new array.
Let me know if it works.
Regards.

YASIN has reacted to this post.
YASIN

Thank's for the suggestion!