Console.log to display data inside of Object in LWC
When we are working with javascript objects in Lightning web components, sometimes we need to check the data inside of that object or array of objects. If we write console.log statemen to view data, then it will simply displays the object{} instead of displaying of the actual data inside that object.So we have to use JSON.stringify() to convert that object into string format to view.
let see with an example.
[import { LightningElement } from 'lwc';let accountDetails = {isSelected: true,Account: {Name: 'Nagarjuna',Industry: 'crm',Phone: 1234567890}};console.log(accountDetails); // Object {2}console.log(JSON.stringify(accountDetails)); // {"isSelected":true,"Account":{"Name":"Nagarjuna","Industry":"crm","Phone":1234567890}}export default class App extends LightningElement {}]
COMMENTS