values object js code example

Example 1: object values javascript

const object1 = {
  a: 'somestring',
  b: 42,
  c: false
};

console.log(Object.values(object1));
// expected output: Array ["somestring", 42, false]

Example 2: javascript object entries

// Object Entries returns object as Array of [key,value] Array
const object1 = {
  a: 'somestring',
  b: 42
}
Object.entries(object1) // Array(2) [["a", "something"], ["b", 42]]
  .forEach(([key, value]) => console.log(`${key}: ${value}`))
// "a: somestring"
// "b: 42"

Example 3: object values

const object1 = {
  a: 'somestring',
  b: 42,
  c: false
};

console.log(Object.values(object1));

// expected output: Array ["somestring", 42, false]

Example 4: listar objetos javascript

libros = ["Brideshead", "Faustus", "Musica"]

function libro(titulo, autor, ISBN) {

    this.titulo = titulo;
    this.autor = autor;
    this.ISBN = ISBN;
    //this.isbn calculo
}

var Brideshead  =  new libro("Retorno a Brideshead", "Evelyn Waugh", 8447308472);
var Faustus = new libro("Doctor Faustus", "Thomas Mann", 9788435018449);
var  Musica = new libro("Una música constante", "Vikram Seth", 9780767904643)
console.log(Object.values(Brideshead))