Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using map with backtick #34498

Closed
prakash03yes opened this issue Jun 29, 2024 · 1 comment
Closed

Using map with backtick #34498

prakash03yes opened this issue Jun 29, 2024 · 1 comment
Labels
closed: question A user misinterpretation or support question. No action required.

Comments

@prakash03yes
Copy link

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

What specific section or headline is this issue about?

array.map inside Template literals

What information was incorrect, unhelpful, or incomplete?

image

When map is used inside Template literals , It automatically puts ","

What did you expect to see?

image

When map is used inside Template literals , It automatically puts ","

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

Keep up the good work.

MDN metadata

Page report details
@prakash03yes prakash03yes added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jun 29, 2024
@github-actions github-actions bot added Content:JS JavaScript docs and removed Content:JS JavaScript docs labels Jun 29, 2024
@Josh-Cena
Copy link
Member

Josh-Cena commented Jun 29, 2024

map returns an array. When an array is stringified, it becomes the elements joined with ,. I don't know what there is to document here:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#string_interpolation:

Template literals coerce their expressions directly to strings,

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion:

Objects are first converted to a primitive by calling its [@@toPrimitive]() (with "string" as hint), toString(), and valueOf() methods, in that order. The resulting primitive is then converted to a string.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map:

A new array with each element being the result of the callback function.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString#description:

The toString method of arrays calls join() internally, which joins the array and returns one string containing each array element separated by commas.

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale Jun 29, 2024
@Josh-Cena Josh-Cena added closed: question A user misinterpretation or support question. No action required. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: question A user misinterpretation or support question. No action required.
Projects
None yet
Development

No branches or pull requests

2 participants