Home > Mobile >  javascript array, object, key:value
javascript array, object, key:value

Time:11-20

Select all the values of objects in the array. For example, tutorials = [{title:a, movie:a}, {title:b, movie:b}, {title:c, movie:c}] => a b c. I want to find the values of the titles of all objects.

Tutorials[number].title was attempted, but it was impossible to obtain the value of the title of all objects.

CodePudding user response:

You can use for loop for this here is the example:

let tutorials = [
    {
        title:'a', movie:'a'
    },
    {
        title:'b', movie:'b'
    }, 
    {
        title:'c', movie:'c'
    }
]

for(let i = 0; i < tutorials.length; i  ) {
    console.log(tutorials[i].title);
}
  • Related