![]() ![]() When you try to access a value out of the index range, you get undefined as the return value. We can access elements through bracket notation, specifying the index inside square brackets. let nobleGases = Array('He', 'Ne', 'Ar', 'Kr', 'Xn') Ĭonsole.log(nobleGases) // Array IndexingĮach element inside an array is identified by its numeric index or position – starting from zero (not 1) in JavaScript, as in many programming languages. Let's create an array of strings, called nobleGases: let nobleGases = Ĭonsole.log(nobleGases) // Īlternatively, you can use the Array() constructor, passing the elements to put inside the array as arguments. You can create an array using a literal syntax – specifying its content inside square brackets, with each item separated by a comma. Arrays can hold values of mixed data types and their size is not fixed. In JavaScript, an array is an object constituted by a group of items having a specific order.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |