Arrays & Objects in JavaScript
objects
// let employee = {
// name: "Harry",
// salary: 10,
// channel: "CodeWithHarry",
// "channel 2": "ProgrammingWithHarry",
// }
// console.log(employee);this is how we create an object
arrays
// let names = [1, 2, 4, "Harry", undefined];
// let names = new Array(41, 2, 4, "Harry", undefined);these are the two ways how we define an array
if we use a broken element in array the we will use it like "harr y"
we will enter it and call it in the same way
let names = new Array(23);this will create a new arrary of 23 empty elements
console.log(names.length);this will give the length of the array
names = names.sort();to sort elements in array
names.push("this is pushed");names.
to add elements in array
Comments
Post a Comment