I am currently working with arrays and pushing objects into an array. Below I have a loop, the inside of CasparJS is used and the links are eliminated and placed in the array. The page link is placed in the array named Page_Link and there is a video link in the array video_link . However, I am trying to merge both arrays in an array. How can I push keys in the array with items?
var page_links = []; Var video_links = []; (Var i = 0; i & lt; categoryUrls.length; i ++) {// Start Loop Casper. ThenOpen (Classes [i], Function () (tryAndScroll (this); casper.then (function () { This GetElementsInfo ('.title'). Each (function) {// Skip Elements is not an href attribute ... if (! Element.attributes.href) {return;} page_links.push (element.attributes) .href); casper.thenOpen (element.attributes.href, function () {this.click ('.responsivewrapper')}}. (Function () {casper.each (this.getElementsInfo ('. Badge-youtube (player) , Element, j) {video_links.push (element ["attribute"] ["src"])}}}}}}}}}}};});} Desired result
{{page_link ':' www.example.com ',' video_link ':' www.example.com '}, {' P Age_link ':' www.example.com ',' video_link ':' www.example.com '}}
In keeping with ARMS, which you can get in any way I do not believe here -
var page_links = ["link1", "link2 "]; Var video_links = ["vlink1", "vlink2"]; In addition to this, the length of the two arrays is also considered (you can apply logic to check it, which I have left here), here is the solution
Var FinalRR = []; (Var ii = 0, ll = page_link height; ii ii ++) {last ARR [ii] = {}; Last ARR [ii] .page_link = Page_Link [ii]; Last ARR [ii] .video_link = video_link [ii]; } Thie finalArr will be updated with the following array description
[{page_link: "link1", video_link: "Vlink1"}, ...];
No comments:
Post a Comment