“Objek log konsol JS” Kode Jawaban

Objek objek Console.log

const language = this.converstaionLanguage; // {"lang":"en"} <- this is JSON

console.log(language); // [object Object]
console.log(JSON.stringify(language) // {"lang":"en"}
Amused Aardvark

Cetak objek javascript

str = JSON.stringify(obj);
str = JSON.stringify(obj, null, 4); // (Optional) beautiful indented output.
console.log(str); // Logs output to dev tools console.
alert(str); // Displays output using window.alert()
Felipebros

Objek log konsol JS

const obj={
    firstName: 'John',
    lastName: 'MacDonald',
    age: 32,
    pets: true
};

console.log(obj); // {firstName: 'John', lastName: 'MacDonald', age: 32, pets: true}
console.log(`${obj}`); // [object Object]
console.log(`${JSON.stringify(obj)}`); // {"firstName":"John","lastName":"MacDonald","age":32,"pets":true}
console.log(Object.keys(obj)); // ['firstName', 'lastName', 'age', 'pets']
console.log(Object.values(obj)); // [ 'John', 'MacDonald', 32, true ]
Anton Grigoriev

Jawaban yang mirip dengan “Objek log konsol JS”

Pertanyaan yang mirip dengan “Objek log konsol JS”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya