Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #14702

Re: JS newbie and Array newbie

From Stefan Weiss <krewecherl@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: JS newbie and Array newbie
Date 2012-06-27 02:37 +0200
Organization albasani.net
Message-ID <jsdl56$5rr$1@news.albasani.net> (permalink)
References <d1e9e795-70bd-498d-8e0d-48511a59cf37@googlegroups.com>

Show all headers | View raw


On 2012-06-27 02:16, robert@theaustinfamily.us wrote:
> Here is what I have - and isn't working for whatever reason;
> 
>   function myPlanet(inPosX, inPosY, inName) {
>         this.posX = inPosX;
>         this.posY = inPosY;
>         this.myName = inName;
>     }
> this is *supposed* to create a new "planet" object (called myPlanet)
> 
> and I call this function with the following code
> var objPlanets = new myPlanet(myX, myY, ****);
> 
> ** my "planet name" - for the time being, I was wanting to use the
> combination of myX and myY and no matter what I try to place into the
> name variable, I can't get it to work!

I don't understand your problem. What you posted should work fine:

  function myPlanet(inPosX, inPosY, inName) {
    this.posX = inPosX;
    this.posY = inPosY;
    this.myName = inName;
  }

  var objPlanets = new myPlanet(23, 34, "the name");

  alert(objPlanets.posX);
  alert(objPlanets.posY);
  alert(objPlanets.myName);

Does this not show three alerts for the three arguments you passed to
the myPlanet constructor?

And what does this have to do with arrays?

- stefan

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

JS newbie and Array newbie robert@theaustinfamily.us - 2012-06-26 17:16 -0700
  Re: JS newbie and Array newbie Stefan Weiss <krewecherl@gmail.com> - 2012-06-27 02:37 +0200
    Re: JS newbie and Array newbie RoLaAus <robert@theaustinfamily.us> - 2012-06-27 16:56 -0700
  Re: JS newbie and Array newbie Gregor Kofler <usenet@gregorkofler.com> - 2012-06-27 11:00 +0200
    Re: JS newbie and Array newbie RoLaAus <robert@theaustinfamily.us> - 2012-06-27 17:01 -0700
      Re: JS newbie and Array newbie "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-06-29 16:45 -0700

csiph-web