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…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

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.