-
Notifications
You must be signed in to change notification settings - Fork 22.4k
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
/en-US/docs/Web/JavaScript/Reference/Template_literals #2371
Comments
I cannot find the issue in the live page.. am I missing anything? |
Both issues are still present.
Those 2 results contradict each other.
is a string of length 5. Whereas the correct output should be:
Furthermore, the second page (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw) consistently refers to "template strings" in the text and the link at the bottom of the page. As the first page indicates, this is an obsolete term. The documentation should reflect the usage in the standard: template literals |
Thanks for getting back @dsletten In the template strings page, instead of the comment, there's this code: As for the 2nd issue, can you tell me where you saw that the term "template string" is obsolete? I could not find that on the template literals page. Thanks! |
Evidently you are referring to the 2nd page: String.raw(). My observation refers to the first page: Template literals. The example shows this result as a literal String:
In JavaScript, that literal value represents a 5-character string. The backslash must be escaped to show that it is a literal '\' and not a newline '\n'. With regard to the 2nd issue, the "Template literals" reference page opens with this statement:
If the language specification no longer uses the term "template strings", then ideally the MDN documentation should reflect this. |
Thanks @dsletten, I've opened a PR to change template strings to template literals. Regarding the first issue, I will leave it for someone else, as I get your point but considering the clarification under it I think it makes sense. However, I could be wrong so I will leave it for someone else to take a look at |
I’ve opened #5903 with a fix for code examples |
* Pushed the fix-fixable-flaws button * Fix code examples in “Template literals” & String.raw() docs Fixes #2371
Request type
Details
The String.raw() example lists incorrect output, indicating that the result of this expression: String.raw
Hi\n${2+3}!
is "Hi\n5!". But that is a 5-element string which contradicts the next line of the example:str.length;
// 6
The output should instead be "Hi\n5!"
Hmm...markdown renders that incorrectly...
The examples on this page are likewise incorrect: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw
This page on String.raw() also uses the term "template string", which appears to be outdated based on the template literal documentation above.
The text was updated successfully, but these errors were encountered: