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…

Scriptcase uses the MVC template?

Maybe you might have thought about this at some point, “Scriptcase uses the MVC templates?" Well, ...

How to implement A2F using Own Development in NodeJS in a Scriptcase application

A2F using Own Development in NodeJS A2F: In a previous article, we talked about Swivel as an extern...

Specialists or generalists, who gets a better advantage by using Scriptcase?

Hey there! Today  we will figure what are the ideal profiles for those who wish to take advantage o...

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.