How to do sorting array object es6

 To sort objects by its vale 

const arr = [ 
 {name:"abc", price: 5},   
 {name:"pqr", price: 3},  
 {name:"mno", price: 2}
 ];

const result = arr.sort((a,b) => a.price-b.price );



Comments

Popular posts from this blog

world tourism guide Template

Es6 how to check if value is not null or undefined?