how to read HashMap in typescript 2.9





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







-2















map = new Map<number, string>();
this.map.set(1, "educadmin");
this.map.set(6, "hr");
this.map.set(7, "tech");
console.log(map);
//process 1
for (let entry of this.map.entries()) {
console.log(entry[0], entry[1]);
}
//process 2
Array.from(map.values(), (value: string) => {
console.log(value);
});


I get this when I logged to the console:



Map(0) {}
size: (...)
__proto__: Map
[[Entries]]: Array(3)
0:{6 => "hr"}
1: {1 => "educadmin"}
2: {7 => "tech"}
length: 3


I want to add get all these values -> hr , educadmin and tech to a string
I tried above 2 process but I am not able to read










share|improve this question




















  • 1





    And your question is...?

    – Jared Smith
    Nov 16 '18 at 18:45











  • I am not able to read the values

    – Rajesh Rajoji
    Nov 16 '18 at 18:46








  • 3





    No luck with what? I'm voting to close this as unclear. Post the code you've tried, along with the desired output and error messages (if any), and I'll consider retracting my close vote. Also not clear at all what this has to do with typescript.

    – Jared Smith
    Nov 16 '18 at 18:51








  • 2





    Read what values? Again, please edit the question with a minimal, complete, verifiable example. Everything you've posted is disjointed and in some cases contradictory. Reading values out of a map is a simple as calling someMap.get(key), if it's not working something else is going on but you haven't posted enough for me to say. Your edit made it worse, not better.

    – Jared Smith
    Nov 16 '18 at 18:57








  • 1





    That's a huge step in the right direction. Now edit the output that you get from running your code into the question and why it isn't correct, because Array.from(map.values()) gives me ["hr", "educadmin", "tech"].

    – Jared Smith
    Nov 16 '18 at 19:25


















-2















map = new Map<number, string>();
this.map.set(1, "educadmin");
this.map.set(6, "hr");
this.map.set(7, "tech");
console.log(map);
//process 1
for (let entry of this.map.entries()) {
console.log(entry[0], entry[1]);
}
//process 2
Array.from(map.values(), (value: string) => {
console.log(value);
});


I get this when I logged to the console:



Map(0) {}
size: (...)
__proto__: Map
[[Entries]]: Array(3)
0:{6 => "hr"}
1: {1 => "educadmin"}
2: {7 => "tech"}
length: 3


I want to add get all these values -> hr , educadmin and tech to a string
I tried above 2 process but I am not able to read










share|improve this question




















  • 1





    And your question is...?

    – Jared Smith
    Nov 16 '18 at 18:45











  • I am not able to read the values

    – Rajesh Rajoji
    Nov 16 '18 at 18:46








  • 3





    No luck with what? I'm voting to close this as unclear. Post the code you've tried, along with the desired output and error messages (if any), and I'll consider retracting my close vote. Also not clear at all what this has to do with typescript.

    – Jared Smith
    Nov 16 '18 at 18:51








  • 2





    Read what values? Again, please edit the question with a minimal, complete, verifiable example. Everything you've posted is disjointed and in some cases contradictory. Reading values out of a map is a simple as calling someMap.get(key), if it's not working something else is going on but you haven't posted enough for me to say. Your edit made it worse, not better.

    – Jared Smith
    Nov 16 '18 at 18:57








  • 1





    That's a huge step in the right direction. Now edit the output that you get from running your code into the question and why it isn't correct, because Array.from(map.values()) gives me ["hr", "educadmin", "tech"].

    – Jared Smith
    Nov 16 '18 at 19:25














-2












-2








-2








map = new Map<number, string>();
this.map.set(1, "educadmin");
this.map.set(6, "hr");
this.map.set(7, "tech");
console.log(map);
//process 1
for (let entry of this.map.entries()) {
console.log(entry[0], entry[1]);
}
//process 2
Array.from(map.values(), (value: string) => {
console.log(value);
});


I get this when I logged to the console:



Map(0) {}
size: (...)
__proto__: Map
[[Entries]]: Array(3)
0:{6 => "hr"}
1: {1 => "educadmin"}
2: {7 => "tech"}
length: 3


I want to add get all these values -> hr , educadmin and tech to a string
I tried above 2 process but I am not able to read










share|improve this question
















map = new Map<number, string>();
this.map.set(1, "educadmin");
this.map.set(6, "hr");
this.map.set(7, "tech");
console.log(map);
//process 1
for (let entry of this.map.entries()) {
console.log(entry[0], entry[1]);
}
//process 2
Array.from(map.values(), (value: string) => {
console.log(value);
});


I get this when I logged to the console:



Map(0) {}
size: (...)
__proto__: Map
[[Entries]]: Array(3)
0:{6 => "hr"}
1: {1 => "educadmin"}
2: {7 => "tech"}
length: 3


I want to add get all these values -> hr , educadmin and tech to a string
I tried above 2 process but I am not able to read







javascript angular6 typescript2.9






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 19:41









Amy

22k1976133




22k1976133










asked Nov 16 '18 at 18:39









Rajesh RajojiRajesh Rajoji

13




13








  • 1





    And your question is...?

    – Jared Smith
    Nov 16 '18 at 18:45











  • I am not able to read the values

    – Rajesh Rajoji
    Nov 16 '18 at 18:46








  • 3





    No luck with what? I'm voting to close this as unclear. Post the code you've tried, along with the desired output and error messages (if any), and I'll consider retracting my close vote. Also not clear at all what this has to do with typescript.

    – Jared Smith
    Nov 16 '18 at 18:51








  • 2





    Read what values? Again, please edit the question with a minimal, complete, verifiable example. Everything you've posted is disjointed and in some cases contradictory. Reading values out of a map is a simple as calling someMap.get(key), if it's not working something else is going on but you haven't posted enough for me to say. Your edit made it worse, not better.

    – Jared Smith
    Nov 16 '18 at 18:57








  • 1





    That's a huge step in the right direction. Now edit the output that you get from running your code into the question and why it isn't correct, because Array.from(map.values()) gives me ["hr", "educadmin", "tech"].

    – Jared Smith
    Nov 16 '18 at 19:25














  • 1





    And your question is...?

    – Jared Smith
    Nov 16 '18 at 18:45











  • I am not able to read the values

    – Rajesh Rajoji
    Nov 16 '18 at 18:46








  • 3





    No luck with what? I'm voting to close this as unclear. Post the code you've tried, along with the desired output and error messages (if any), and I'll consider retracting my close vote. Also not clear at all what this has to do with typescript.

    – Jared Smith
    Nov 16 '18 at 18:51








  • 2





    Read what values? Again, please edit the question with a minimal, complete, verifiable example. Everything you've posted is disjointed and in some cases contradictory. Reading values out of a map is a simple as calling someMap.get(key), if it's not working something else is going on but you haven't posted enough for me to say. Your edit made it worse, not better.

    – Jared Smith
    Nov 16 '18 at 18:57








  • 1





    That's a huge step in the right direction. Now edit the output that you get from running your code into the question and why it isn't correct, because Array.from(map.values()) gives me ["hr", "educadmin", "tech"].

    – Jared Smith
    Nov 16 '18 at 19:25








1




1





And your question is...?

– Jared Smith
Nov 16 '18 at 18:45





And your question is...?

– Jared Smith
Nov 16 '18 at 18:45













I am not able to read the values

– Rajesh Rajoji
Nov 16 '18 at 18:46







I am not able to read the values

– Rajesh Rajoji
Nov 16 '18 at 18:46






3




3





No luck with what? I'm voting to close this as unclear. Post the code you've tried, along with the desired output and error messages (if any), and I'll consider retracting my close vote. Also not clear at all what this has to do with typescript.

– Jared Smith
Nov 16 '18 at 18:51







No luck with what? I'm voting to close this as unclear. Post the code you've tried, along with the desired output and error messages (if any), and I'll consider retracting my close vote. Also not clear at all what this has to do with typescript.

– Jared Smith
Nov 16 '18 at 18:51






2




2





Read what values? Again, please edit the question with a minimal, complete, verifiable example. Everything you've posted is disjointed and in some cases contradictory. Reading values out of a map is a simple as calling someMap.get(key), if it's not working something else is going on but you haven't posted enough for me to say. Your edit made it worse, not better.

– Jared Smith
Nov 16 '18 at 18:57







Read what values? Again, please edit the question with a minimal, complete, verifiable example. Everything you've posted is disjointed and in some cases contradictory. Reading values out of a map is a simple as calling someMap.get(key), if it's not working something else is going on but you haven't posted enough for me to say. Your edit made it worse, not better.

– Jared Smith
Nov 16 '18 at 18:57






1




1





That's a huge step in the right direction. Now edit the output that you get from running your code into the question and why it isn't correct, because Array.from(map.values()) gives me ["hr", "educadmin", "tech"].

– Jared Smith
Nov 16 '18 at 19:25





That's a huge step in the right direction. Now edit the output that you get from running your code into the question and why it isn't correct, because Array.from(map.values()) gives me ["hr", "educadmin", "tech"].

– Jared Smith
Nov 16 '18 at 19:25












1 Answer
1






active

oldest

votes


















0














I think you are looking for a solution to get the keys/values as arrays.



let keysAsArray = Array.from(map.keys());
let valueAsArray = Array.from(map.values());

console.log(keysAsArray);
console.log(valueAsArray);


The output is



[1, 6, 7]
["educadmin", "hr", "tech"]





share|improve this answer
























  • Yeah. I tried this way. But it does it work. I’m getting empty array. My typescript Version is 2.9 and using ecma 5. Do you feel that your code still supports these versions.

    – Rajesh Rajoji
    Nov 17 '18 at 1:03






  • 1





    Map is introduced in ES6. You need to use polyfil. Can you take a look at this, this, and this to get more insights and eventually to solve your issue ?

    – Charmis Varghese
    Nov 17 '18 at 22:14












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343623%2fhow-to-read-hashmap-in-typescript-2-9%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I think you are looking for a solution to get the keys/values as arrays.



let keysAsArray = Array.from(map.keys());
let valueAsArray = Array.from(map.values());

console.log(keysAsArray);
console.log(valueAsArray);


The output is



[1, 6, 7]
["educadmin", "hr", "tech"]





share|improve this answer
























  • Yeah. I tried this way. But it does it work. I’m getting empty array. My typescript Version is 2.9 and using ecma 5. Do you feel that your code still supports these versions.

    – Rajesh Rajoji
    Nov 17 '18 at 1:03






  • 1





    Map is introduced in ES6. You need to use polyfil. Can you take a look at this, this, and this to get more insights and eventually to solve your issue ?

    – Charmis Varghese
    Nov 17 '18 at 22:14
















0














I think you are looking for a solution to get the keys/values as arrays.



let keysAsArray = Array.from(map.keys());
let valueAsArray = Array.from(map.values());

console.log(keysAsArray);
console.log(valueAsArray);


The output is



[1, 6, 7]
["educadmin", "hr", "tech"]





share|improve this answer
























  • Yeah. I tried this way. But it does it work. I’m getting empty array. My typescript Version is 2.9 and using ecma 5. Do you feel that your code still supports these versions.

    – Rajesh Rajoji
    Nov 17 '18 at 1:03






  • 1





    Map is introduced in ES6. You need to use polyfil. Can you take a look at this, this, and this to get more insights and eventually to solve your issue ?

    – Charmis Varghese
    Nov 17 '18 at 22:14














0












0








0







I think you are looking for a solution to get the keys/values as arrays.



let keysAsArray = Array.from(map.keys());
let valueAsArray = Array.from(map.values());

console.log(keysAsArray);
console.log(valueAsArray);


The output is



[1, 6, 7]
["educadmin", "hr", "tech"]





share|improve this answer













I think you are looking for a solution to get the keys/values as arrays.



let keysAsArray = Array.from(map.keys());
let valueAsArray = Array.from(map.values());

console.log(keysAsArray);
console.log(valueAsArray);


The output is



[1, 6, 7]
["educadmin", "hr", "tech"]






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 16 '18 at 19:38









Charmis VargheseCharmis Varghese

906




906













  • Yeah. I tried this way. But it does it work. I’m getting empty array. My typescript Version is 2.9 and using ecma 5. Do you feel that your code still supports these versions.

    – Rajesh Rajoji
    Nov 17 '18 at 1:03






  • 1





    Map is introduced in ES6. You need to use polyfil. Can you take a look at this, this, and this to get more insights and eventually to solve your issue ?

    – Charmis Varghese
    Nov 17 '18 at 22:14



















  • Yeah. I tried this way. But it does it work. I’m getting empty array. My typescript Version is 2.9 and using ecma 5. Do you feel that your code still supports these versions.

    – Rajesh Rajoji
    Nov 17 '18 at 1:03






  • 1





    Map is introduced in ES6. You need to use polyfil. Can you take a look at this, this, and this to get more insights and eventually to solve your issue ?

    – Charmis Varghese
    Nov 17 '18 at 22:14

















Yeah. I tried this way. But it does it work. I’m getting empty array. My typescript Version is 2.9 and using ecma 5. Do you feel that your code still supports these versions.

– Rajesh Rajoji
Nov 17 '18 at 1:03





Yeah. I tried this way. But it does it work. I’m getting empty array. My typescript Version is 2.9 and using ecma 5. Do you feel that your code still supports these versions.

– Rajesh Rajoji
Nov 17 '18 at 1:03




1




1





Map is introduced in ES6. You need to use polyfil. Can you take a look at this, this, and this to get more insights and eventually to solve your issue ?

– Charmis Varghese
Nov 17 '18 at 22:14





Map is introduced in ES6. You need to use polyfil. Can you take a look at this, this, and this to get more insights and eventually to solve your issue ?

– Charmis Varghese
Nov 17 '18 at 22:14




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53343623%2fhow-to-read-hashmap-in-typescript-2-9%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Bressuire

Vorschmack

Quarantine