You Might Not Be Familiar with These Things about the JavaScript Array – 1

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.

Almost all programming languages have common properties for an array. In this article, we are going to discuss one of the three important things you probably do not know about JavaScript arrays.

Adding Custom Properties to Array

There are three types of properties that you can add to a JavaScript array.

Indices of an array

Predefined or built-in properties

Custom properties

Every beginner developer is familiar with the first two properties. Experienced developers regularly use all three properties.

Indices as Properties

In JavaScript, the syntax of creating an array is:

var ary = [“eyes”,”hands”,”ears”];

Indices are properties of array elements and are always positive integers. Just as we have a key-value pair in an object, we have an index-element pair in JavaScript array. Indices are different from other built-in properties of an array. A developer can set an element in the index with bracket syntax.

For example

ary[3] =”xyz”;

Built-In Properties

There are some properties that are frequently used by developers. Therefore, these properties are predefined in JavaScript library. One of the examples of built-in properties is length. These properties are also used to customize generic objects for different needs.

There are two ways for accessing built-in properties:

object.key

or, ary[“key”]

In var ary = [“eyes”,”hands”,”ears”];

ary.length will return 3 and ary[“length”] will also return 3.

Adding Custom Properties

In JavaScript array, usually, a developer needs not to create and add a custom property. This is the reason why beginners are not taught how they can create and add custom properties to a JavaScript array. However, a developer may encounter a special case in which he has to define and add a custom property.

In the following example, we have created a property to identify the class of an array.

Var ary=[“eyes”,”hands”,”ears”];

ary.itemClass =”bodyParts”;

console.log(ary+ ”are” +ary.itemClass);

The output will be “eyes, hands, ears are bodyParts”

Every program written in JavaScript or any other programming languages consists of at least one array. If you are working as a freelance website developer in Singapore, you know how important arrays are. Even if you are an experienced developer, there is still more to explore in JavaScript.

What-is-a-WordPress-plugin-by-Subraa-Freelance-WordPress-Developer-Singapore

02 Jan 2020

Be it a basic website or a business website design, it has become easier to develop with less to no knowledge of coding. One of the most popular sites that allows you to create your own website or blog no matter how new you are to website-building, is WordPress.  What is a WordPress plugin by … Continue reading “What is a WordPress Plugin?”

Tags: , , , , , , , ,
Features of Startup Website

22 Sep 2025

Your website isn’t an accessory; it’s the core of your online presence. Small entrepreneurs, business owners and marketers investing in a professionally developed website can be a game changer. With so many pricing options available, an issue is often asked about the cost of a website design in Singapore.

Tags: , , ,
Why-WordPress-Themes-are-necessary-for-a-Website-in-2020-by-Subraa-Freelance-Web-Designer-Singapore

04 Jan 2020

Websites built in WordPress CMS powers 34% of the internet and it is the most preferred content management system by any freelance web designer in Singapore. Websites are either custom designed or developed based on themes. If you are running on a budget or is okay to have your websites built over a design which is … Continue reading “Why WordPress Themes are necessary?”

Tags: , , , , , , , , , ,