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


Groups > comp.lang.javascript > #18267 > unrolled thread

Problem with Map in Javascript

Started byJeovane Reges <jeovane.reges@gmail.com>
First post2013-01-26 14:12 -0800
Last post2013-02-05 18:31 -0800
Articles 7 — 6 participants

Back to article view | Back to comp.lang.javascript


Contents

  Problem with Map in Javascript Jeovane Reges <jeovane.reges@gmail.com> - 2013-01-26 14:12 -0800
    Re: Problem with Map in Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-01-26 23:55 +0100
      Re: Problem with Map in Javascript Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-01-26 20:13 -0700
        Re: Problem with Map in Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-01-27 18:53 +0100
          Re: Problem with Map in Javascript Tim Streater <timstreater@greenbee.net> - 2013-01-27 18:03 +0000
    Re: Problem with Map in Javascript Danny <dann90038@gmail.com> - 2013-01-26 15:07 -0800
    Re: Problem with Map in Javascript Scott Sauyet <scott.sauyet@gmail.com> - 2013-02-05 18:31 -0800

#18267 — Problem with Map in Javascript

FromJeovane Reges <jeovane.reges@gmail.com>
Date2013-01-26 14:12 -0800
SubjectProblem with Map in Javascript
Message-ID<be3b2628-535a-4137-82b3-4c9608d99802@googlegroups.com>
Hello all, good night.
Guys IM trying to create a Map (Map <k,v> in java) in javascript, where the keys and values are added dynamically, however, when I try to "create" them dynamically always ends up giving error.

My code -> http://pastebin.com/NZxjpDvg

However, the way that my code be, even if I add two values belonging to the same key, it always falls on else besides overwrite the existing values.
And if I add a new Key instead of being created a new array what happens is that this new overwrites the previous one.

Someone can tell me what should I do to fix my code?
Since already thank you for everyone's help.

[toc] | [next] | [standalone]


#18268

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-01-26 23:55 +0100
Message-ID<XnsA154F36DDB6Eeejj99@194.109.133.133>
In reply to#18267
Jeovane Reges wrote on 26 jan 2013 in comp.lang.javascript:

> Hello all, good night.
> Guys IM trying to create a Map (Map <k,v> in java) in javascript,
> where the keys and values are added dynamically, however, when I try
> to "create" them dynamically always ends up giving error. 
> 
> My code -> http://pastebin.com/NZxjpDvg
> 
> However, the way that my code be, even if I add two values belonging
> to the same key, it always falls on else besides overwrite the
> existing values. And if I add a new Key instead of being created a new
> array what happens is that this new overwrites the previous one. 
> 
> Someone can tell me what should I do to fix my code?
> Since already thank you for everyone's help.

Javascript is not a script version of Java, but a totally different 
language group.

It's scripts are not called "Javascripts", but "Javascript scripts".

There is even a longtime member of this NG, who maintains that Javascript 
doesn't even exist, so we cannot figure out why he still frequents this 
NG. Many of us, me too, value his input, though.

So please learn some Javascript first.

btw, this is an emancipated NG, not all of us being guys.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18274

FromMartin Leese <please@see.Web.for.e-mail.INVALID>
Date2013-01-26 20:13 -0700
Message-ID<ke2613$j6p$1@dont-email.me>
In reply to#18268
Evertjan. wrote:
...
> btw, this is an emancipated NG, not all of us being guys.

Up here in the snowy wastes of Canada, guys
is non-gender specific.

I remember sitting in a bar watching a
female server approach a table of women
with the question, "Do you guys want
anything to drink?"

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/

[toc] | [prev] | [next] | [standalone]


#18275

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2013-01-27 18:53 +0100
Message-ID<XnsA155C03DB23C0eejj99@194.109.133.133>
In reply to#18274
Martin Leese wrote on 27 jan 2013 in comp.lang.javascript:

> Evertjan. wrote:
> ...
>> btw, this is an emancipated NG, not all of us being guys.
> 
> Up here in the snowy wastes of Canada, guys
> is non-gender specific.

Perhaps your guys ARE not gender-specific?
What a snowy waste of singular impersonality.
Strange world you live in.
 
> I remember sitting in a bar watching a
> female server approach a table of women
> with the question, "Do you guys want
> anything to drink?"

The peope over there perhaps were linguistically nostalgic
to the lalguages of the "old countries"?
The English "you" has no plural, 
while the Dutch "jij/je/jou" has the plural "jullie"
which originated from "je lui", "je lieden", 
meaning "you people" or "you guys".

Anyway [do you say "anyways", by-the-way[s?]?], this is an international 
NG, were only the Javascript language is on topic, so better not use local 
slang, and[/or] clearly state your location in the signature.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#18276

FromTim Streater <timstreater@greenbee.net>
Date2013-01-27 18:03 +0000
Message-ID<timstreater-96DD83.18035827012013@news.individual.net>
In reply to#18275
In article <XnsA155C03DB23C0eejj99@194.109.133.133>,
 "Evertjan." <exxjxw.hannivoort@inter.nl.net> wrote:

> Martin Leese wrote on 27 jan 2013 in comp.lang.javascript:

> Anyway [do you say "anyways", by-the-way[s?]?],

No, that is a US-only affectation.

> this is an international NG, were only the Javascript language is
> on topic, so better not use local slang, and[/or] clearly state
> your location in the signature.

It's not specifically Canada, more North America I'd say.

-- 
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

[toc] | [prev] | [next] | [standalone]


#18269

FromDanny <dann90038@gmail.com>
Date2013-01-26 15:07 -0800
Message-ID<2e80a185-bf39-4ec7-9aac-ac302ffc481f@googlegroups.com>
In reply to#18267
To Jeovane Reges

Your material seems to be a jQuery issue, not a js per se, nevertheless, see if this helps -> https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/map

[toc] | [prev] | [next] | [standalone]


#18358

FromScott Sauyet <scott.sauyet@gmail.com>
Date2013-02-05 18:31 -0800
Message-ID<3826068b-be4a-4b3b-ae49-fd74abf781e8@14g2000vbr.googlegroups.com>
In reply to#18267
Jeovane Reges wrote:
> IM trying to create a Map (Map <k,v> in java) in javascript,
> where the keys and values are added dynamically, however, when
> I try to "create" them dynamically always ends up giving error.
>
> My code -> http://pastebin.com/NZxjpDvg

Sorry for the late response.  I'm finding very little time for this
group at the moment.

As others have pointed out, please be sure to not to confuse Java and
Javascript.  The name similarity was an unfortunate result of a
marketing deal between Sun and Netscape.  The languages themselves
share little beyond some superficial syntactic constructs.

What you're looking to do is quite simple in Javascript, so long as
your keys are Strings.  You don't really need to define a special
"class" for it:

    var myMap = {};
    myMap[key] = value; // put
    var val = myMap[key]; // get

If your keys are not Strings, this will take significantly more work,
although there are techniques you can use.

  -- Scott

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web