Working with objects is the only way to manipulate arrays or any other object in the JavaScript language. For example, it is necessary to implement a client list. The object can be implemented as follows:

 

Function CreateClients (name, address, telephone, rent)

{

this.name = name;

this.address = address;

this. phone = phone;

this.income = income;

}

The property “this” specifies the current object as a source of values ​​passed to the function. Now, just create the object:

 

Maria = New CreateClients (‘Maria Aparecida’, ‘Guillotine Rua dos Patos, S / N’, ‘332-1148’, 1300)

 

To access the properties of Maria object, simply use the following syntax:

Maria.name -> returns ‘Maria Aparecida’

Maria.address -> returns ‘Guillotine Rua dos Patos, S / N’

Maria.phone -> returns ‘332-1148’

Maria.income -> returns in 1300

Objects in Javascript

Another way to reference the properties of Maria’s object is:

Maria [0], Maria [1] Maria [2] Maria [3]

 

To create arrays, a more practical approach could be the following:

Function Matrix (n)

{

this.length = n

for (var counter = 1; counter <= n; conatdor = counter + 1)

{

this [counter] = “”

}

}

 

To create our array, then we would use the following command:

Month = matrix (12)

 

The next step would include only the data:

Month [1] = ‘January’

Month [2] = ‘February’

Month [12] = ‘December’

 

Finally, it is also possible to use both methods simultaneously:

New customers = Array (3)

Clients [1] = New CreateClients (“Charlene”, “Street A 51”, “331-0376”, 1150)

Customers [2] = New CreateClients (“Joseph”, “Street of Covenants, S / N,” “332-2781”, 950)

Customers [3] = New CreateClients (“James Manson,” “Joy Street, 171 ‘, 1000)

 

So obtaining the following scenario:

Customers [1] .name = “Charlene”

Customers [2] .phone = “332-2781”

Customers [3] = null .phone

You might also like…

AJAX: What it is and how to use it in Scriptcase

Hello, in this post we will conceptually understand the AJAX event and how use  inside the Scriptca...

What advantages for a company in adopting a low-code tool?

Let's understand how low-code tools have become a facilitator in the web development process as they...

How to implement A2F using Swivel in a Scriptcase application

I want to start talking about Swivel, Swivel is a provider of authentication solutions who have been...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.