Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get value in array object value using for loop in javascript

const myArray = [{x:100}, {x:200}, {x:300}];

const newArray= myArray.map(element => element.x);
console.log(newArray); // [100, 200, 300]
Comment

how to get value in array object value using for loop in javascript

const people = [ {name: "john", age:23},
                {name: "john", age:43},
                {name: "jim", age:101},
                {name: "bob", age:67} ];

const john = people.find(person => person.name === 'john');
console.log(john);
Comment

how to get value in array object value using for loop in javascript

const people = [
    {name: 'John', age: 23}, 
    {name: 'Andrew', age: 3}, 
    {name: 'Peter', age: 8}, 
    {name: 'Hanna', age: 14}, 
    {name: 'Adam', age: 37}];

const anyAdult = people.some(person => person.age >= 18);
console.log(anyAdult); // true
Comment

how to get value in array object value using for loop in javascript

const people = [
  { name: "John", age: 21 },
  { name: "Peter", age: 31 },
  { name: "Andrew", age: 29 },
  { name: "Thomas", age: 25 }
];

let sortByAge = people.sort(function (p1, p2) {
  return p1.age - p2.age;
});

console.log(sortByAge);
Comment

how to get value in array object value using for loop in javascript

const myArray = [{x:100}, {x:200}, {x:300}];

const sum = myArray.map(element => element.x).reduce((a, b) => a + b, 0);
console.log(sum); // 600 = 0 + 100 + 200 + 300

const average = sum / myArray.length;
console.log(average); // 200
Comment

PREVIOUS NEXT
Code Example
Javascript :: js download file from webserver 
Javascript :: javascript palindrome 
Javascript :: javascript array from string 
Javascript :: dummy data json 
Javascript :: javascript get params from query string json object 
Javascript :: javascript simple hash 
Javascript :: flatten nested json objects 
Javascript :: antd react 
Javascript :: string padStart padEnd 
Javascript :: cookies in react native 
Javascript :: convert string to float javascript 
Javascript :: canvas drawimage resize quality 
Javascript :: onclick hold react 
Javascript :: express get 
Javascript :: change page javascript 
Javascript :: handling event in jsx 
Javascript :: functions in javascript 
Javascript :: return new array on sort js 
Javascript :: download pdf in javascript 
Javascript :: redux saga fetch data 
Javascript :: javascript list class properties 
Javascript :: send multipart form data axios with node js 
Javascript :: print array angular 
Javascript :: kendo grid toolbar custom button click event jquery 
Javascript :: decimal to base 32 javascript 
Javascript :: print an object in javascript 
Javascript :: javascript import class 
Javascript :: javascript append list 
Javascript :: vue 3 install eslint 
Javascript :: js add element to array 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =