javascript-dasar-arrayObject

Run Settings
LanguageJavascript
Language Version
Run Command
/* untuk menjalankan berkas ini, pastikan pada konfigurasi run setting -> run command Anda menetapkan nilai "node object.js" */ // inisialisasi objek ke variabel let object = {key1: "value1", key2: "value2", key3: "value3"} let user = { firstName: "Harry", lastName: "Potter", age: 20, isMuggle: false, stuff: ["Magic Wind", "Flying Car", "Owl"] }; console.log("Hallo, nama saya " + user.firstName + " " + user.lastName); console.log("Umur saya " + user.age + " tahun"); /* output Hallo, nama saya Harry Potter Umur saya 20 tahun */ let user2 = { name: { first: "Rahmad", last: "Aji" }, age: 20, isMuggle: false, hobby: ["Programming", "Music"] } console.log("Hallo, nama saya " + " " + user2.name.last+ ". Hobby saya "+ user2.hobby[1]); /* output Hallo, nama saya Harry Potter */
/* untuk menjalankan berkas ini, pastikan pada konfigurasi run setting -> run command Anda menetapkan nilai "node arrays.js" */ let myArray = ["Coklat", 42.5, 22, true, "Programming"]; console.log(myArray); /* output: [ 'Coklat', 42.5, 22, true, 'Programming' ] */ console.log(myArray[1]); /* output: 42.5 */ console.log(myArray[0]); console.log(myArray[1]); console.log(myArray[2]); console.log(myArray[3]); console.log(myArray[4]); console.log(myArray[5]); console.log("Panjang nilai myArray adalah " + myArray.length + "."); /* output: Coklat 42.5 22 true Programming undefined Panjang nilai myArray adalah 5. */
let nilai = [12,25,47,28]; console.log(nilai[nilai.length-1]); console.log(nilai[nilai.length-2]); console.log(nilai[nilai.length-3]);
Editor Settings
Theme
Key bindings
Full width
Lines