Click here to Skip to main content
15,562,903 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionNeed Help with Drag n Drop... Pin
VernonM21-Dec-22 11:26
VernonM21-Dec-22 11:26 
AnswerRe: Need Help with Drag n Drop... Pin
Richard Deeming21-Dec-22 22:26
mveRichard Deeming21-Dec-22 22:26 
GeneralRe: Need Help with Drag n Drop... Pin
VernonM22-Dec-22 6:50
VernonM22-Dec-22 6:50 
QuestionJavascript cookies Pin
Member 158197443-Nov-22 21:46
Member 158197443-Nov-22 21:46 
AnswerRe: Javascript cookies Pin
Jeremy Falcon17-Nov-22 14:32
professionalJeremy Falcon17-Nov-22 14:32 
AnswerRe: Javascript cookies Pin
JohnG1013-Dec-22 1:40
JohnG1013-Dec-22 1:40 
Questionwhy javascript onchange not triggered for persian characters ? Pin
shaho zakaryaee23-Oct-22 22:47
shaho zakaryaee23-Oct-22 22:47 
AnswerRe: why javascript onchange not triggered for persian characters ? Pin
Richard Deeming23-Oct-22 22:49
mveRichard Deeming23-Oct-22 22:49 
AnswerRe: why javascript onchange not triggered for persian characters ? Pin
shaho zakaryaee23-Oct-22 22:58
shaho zakaryaee23-Oct-22 22:58 
GeneralRe: why javascript onchange not triggered for persian characters ? Pin
Jeremy Falcon26-Oct-22 12:10
professionalJeremy Falcon26-Oct-22 12:10 
QuestionDodger game with eventListener Pin
Ali Ibrahim jasim16-Oct-22 3:54
Ali Ibrahim jasim16-Oct-22 3:54 
AnswerRe: Dodger game with eventListener Pin
Jeremy Falcon26-Oct-22 12:26
professionalJeremy Falcon26-Oct-22 12:26 
QuestionHTML5 Nested drag and drop using vuejs2 Pin
Maseeha K1-Oct-22 0:40
Maseeha K1-Oct-22 0:40 
AnswerRe: HTML5 Nested drag and drop using vuejs2 Pin
Jeremy Falcon26-Oct-22 12:12
professionalJeremy Falcon26-Oct-22 12:12 
Questiontrying to get to grips with parsing from a JSON file Pin
DSB Audio (David Sweeney-Bear)30-Sep-22 5:22
DSB Audio (David Sweeney-Bear)30-Sep-22 5:22 
AnswerRe: trying to get to grips with parsing from a JSON file Pin
Richard MacCutchan30-Sep-22 5:53
mveRichard MacCutchan30-Sep-22 5:53 
GeneralRe: trying to get to grips with parsing from a JSON file Pin
DSB Audio (David Sweeney-Bear)30-Sep-22 6:42
DSB Audio (David Sweeney-Bear)30-Sep-22 6:42 
GeneralRe: trying to get to grips with parsing from a JSON file Pin
Richard MacCutchan30-Sep-22 6:49
mveRichard MacCutchan30-Sep-22 6:49 
GeneralRe: trying to get to grips with parsing from a JSON file Pin
DSB Audio (David Sweeney-Bear)30-Sep-22 8:57
DSB Audio (David Sweeney-Bear)30-Sep-22 8:57 
GeneralRe: trying to get to grips with parsing from a JSON file Pin
Dom8615-Nov-22 5:33
Dom8615-Nov-22 5:33 
GeneralRe: trying to get to grips with parsing from a JSON file Pin
DSB Audio (David Sweeney-Bear)30-Sep-22 6:35
DSB Audio (David Sweeney-Bear)30-Sep-22 6:35 
GeneralRe: trying to get to grips with parsing from a JSON file Pin
Richard MacCutchan30-Sep-22 6:50
mveRichard MacCutchan30-Sep-22 6:50 
AnswerRe: trying to get to grips with parsing from a JSON file Pin
DSB Audio (David Sweeney-Bear)30-Sep-22 11:12
DSB Audio (David Sweeney-Bear)30-Sep-22 11:12 
I've now solved this little conundrum and glad to have learned a little more about arrays.
  • There was no need to parse from a JSON file, really I just needed an array of objects, however, I didn't "convert" the JSON properly:
(videoList.json)
{
  "videoList":[
    {
      "name":"Vid One", 
      "index":0, 
      "thumbLink":"assets/vid1.jpg", 
      "playLink": "http://some.tube/video1"
    },
    {
      "name":"Vid Two", 
      "index":1, 
      "thumbLink":"assets/vid2.jpg", 
      "playLink": "https://some.tube/video2"
    }
  ]
}

in js becomes:

(videoList.js)
var videoList = [
    {
      name:"Vid One", 
      index:0, 
      thumbLink:"assets/vid1.jpg", 
      playLink: "http://some.tube/video1"
    },
    {
      name:"Vid Two", 
      index:1, 
      thumbLink:"assets/vid2.jpg", 
      playLink: "https://some.tube/video2"
    }
  ]

(my mistake was that I failed to remove the quotations around "name")
  • in order to get, say, all the "names" into a new array, 'array.map' does the job:
    let names=videoList.map( (item) => item.name);
which gives me a new array containing all the "name" values.

Moving forward, I should be able to do all sorts of useful and interesting things with my youtube videos on my site... At this moment in time, I'd rather maintain a manual list than start wrestling with the YT API!
AnswerRe: trying to get to grips with parsing from a JSON file Pin
jkirkerx14-Dec-22 13:25
professionaljkirkerx14-Dec-22 13:25 
QuestionSecond chart not react to data entered, why? Explain, please, how to solve the issue? Pin
Earl Lembertas27-Sep-22 11:35
Earl Lembertas27-Sep-22 11:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.