Mwansa Matimba Posted on Dec 14, 2022 are javascript arrays dynamic #gratitude are javascript arrays dynamic Top comments (1) Subscribe Personal Trusted User Create template Templates let you quickly answer FAQs or store snippets for re-use. Submit Preview Dismiss Collapse Expand Gil Fewster Gil Fewster Gil Fewster Follow Web developer, tinkerer, take-aparterer (and, sometimes, put-back-togetherer) Location Melbourne, Australia Work Front End Developer at Art Processors Joined Jul 23, 2019 • Dec 14 '22 Dropdown menu Copy link Hide Yes! JavaScript arrays: can be declared without an explicit length, and will automatically increase in length as items are added can be resized at any time explicitly in your code, or dynamically at runtime can contain elements with any combination of types can replace an element of any type with an element of any other type const myArray = new Array(); console.log(myArray.length); // 0 console.log(myArray); // [] myArray.push("a",9,{name: 'bob'}); console.log(myArray.length); // 3 console.log(myArray); // [ 'a', 9, { name: 'bob' } ] myArray[0] = 42 console.log(myArray.length); // 3 console.log(myArray); // [ 42, 9, { name: 'bob' } ] myArray[2] = undefined console.log(myArray.length); // 3 console.log(myArray); // [ 42, 9, undefined ] myArray.length = 2 console.log(myArray.length); // 2 console.log(myArray); // [ 42, 9 ] Enter fullscreen mode Exit fullscreen mode Code of Conduct • Report abuse Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse
Top comments (1)
Yes!
JavaScript arrays: