-
October 3rd, 2011, 05:10 AM
#1
JavaScript: Create an array of objects
Hi guys and gals, I have a list of about 70 servo's that I'd like to apply set properties too.
As they all have the same property set but with different values I thought I'd try creating a servo object, the create an array of servo's but I don't think I'm getting anywhere fast.
Heres what I have
PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
function servo(application,class,type,motor,bearings,gears,modelno,name,speed,weight,dimensions,opvoltage,image,description)
{
this.application=application;
this.class=class;
this.type=type;
this.motor=motor;
this.bearings=bearings;
this.modelno=modelno;
this.name=name;
this.speed=speed;
this.weight=weight;
this.dimensions=dimensions;
this.opvoltage=opvoltage;
this.image=image;
this.description=description;
}
servo= new Object Array();
servo.application = 1;
servo.class = 2;
</script>
</head>
<body>
</body>
</html>
Where am I going wrong?
Once this is done and I've got all the servo objects created with their properties, I'm hoping to be able to search for all servo's with a set property i.e all servo's with servo.application = 1
would that be possible, if not I geuss I'd be wasting all our time trying to create classes I can't use the way I'd like.
Last edited by lil_bugga; October 3rd, 2011 at 05:19 AM.
-
October 6th, 2011, 05:33 PM
#2
Re: Create an array of objects
If you're "querying" multiple objects through multiple indexes then you're going to have to iterate the array. The more objects in the array...the slower that will go. Why don't you just use a database?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|