// OBJECTS IN JS let myBook = { title: 'The 4 little Birds', Author: 'Okile Mousa', numberOfPages: 230, colorOfCover: 'Maroon', isAvailable: true, typeOfCover: 'Hard & Soft', price: 35.99 }; console.log(myBook); // console.log (myBook) RESULT [object Object] { author: "Okile Mousa", colorOfCover: "Maroon", isAvailable: true, numberOfPages: 230, price: 35.99, title: "The 4 little Birds", typeOfCover: "Hard & Soft" } //single Object access console.log(myBook.title); // "The 4 little Birds" console.log(myBook.author); // "Okile Mousa" console.log(myBook.numberOfPages); // 230 console.log(myBook.isAvailable); // true console.log(myBook.price); // 35.99 etc... // CLASSES IN JS class Car { constructor(name, model, size, price) { this.name = name; this.model = model; this.size = size; this.price = price; } }; // class access let newCar = new Car('Mousat One', 2023, '350 Tonnes', 35000); console.log(newCar); // console.log (newCar) RESULT [object Object] { model: 2023, name: "Mousat One", price: 35000, size: "350 Tonnes" } // ARRAYS IN JS let guests = ['Mirjam Boßmeyer', 'Izaan M Okile', 'Liam Barsch', 'Okile M Ebokorait']; console.log(guests); // ["Mirjam Boßmeyer", "Izaan M Okile", "Liam Barsch", "Okile M Ebokorait"] console.log(guests[2]); //"Liam Barsch" console.log(guests[0]); //"Mirjam Boßmeyer" etc... /*array access let firstGuest = 'Mirjam Boßmeyer'; let secondGuest = 'Izaan M Okile'; let thirdGuest = 'Liam Barsch'; let fourthGuest = 'Okile M Ebokorait'; */ console.log(firstGuest); // "Mirjam Boßmeyer" console.log(secondGuest);// "Izaan M Okile" etc... //ulternatively accessed as ab object let firstGuest = {name:'Mirjam Boßmeyer', vip: true}; let secondGuest = {name:'Izaan M Okile', vip: true}; let thirdGuest = {name:'Liam Barsch', vip: true}; let fourthGuest = {name:'Okile M Ebokorait', vip: false}; guests = [firstGuest, secondGuest, thirdGuest, fourthGuest]; console.log(guests); // console.log(guests)RESULT [[object Object] { name: "Mirjam Boßmeyer", vip: true }, [object Object] { name: "Izaan M Okile", vip: true }, [object Object] { name: "Liam Barsch", vip: true }, [object Object] { name: "Okile M Ebokorait", vip: false }]
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter