In today’s digital age, having a strong online presence is crucial for individuals and businesses alike. Whether you’re launching an informational website, blog, an e-commerce site, or an online portfolio, your web page is often the first point of contact between you and your audience. That’s where domain and hosting come in. A domain is … Continue reading “Understanding Domain and Web Hosting: A Beginner’s Guide to Choosing the Right Service for Your Website”
Every programming element is important. However, the array is special. It enables you to use a single variable to refer the storage of multiple variables. With an array, it has become much easier to handle multiple values. There are some limitations of this referenced data type. This is the reason why Java, C#, and other high-level languages rely on objects to store values of different primitive data types. However, still, arrays are very important element of middle and high-level programming languages.
Adding Custom Properties to Array
Indices of an array
Predefined or built-in properties
Every beginner developer is familiar with the first two properties. Experienced developers regularly use all three properties.
Indices as Properties
var ary = [“eyes”,”hands”,”ears”];
There are two ways for accessing built-in properties:
In var ary = [“eyes”,”hands”,”ears”];
ary.length will return 3 and ary[“length”] will also return 3.
Adding Custom Properties
In the following example, we have created a property to identify the class of an array.
console.log(ary+ ”are” +ary.itemClass);
The output will be “eyes, hands, ears are bodyParts”