This question already has answers here:
Why JavaScript Compressors replace single quotes with double quotes?
(1 answer)
How does Google Closure Compiler handle quotes (string literals)?
(1 answer)
Closed 3 years ago.
I have the following line of Javascript code:
shell.flash.success('Some string');
However in Chrome Developer Tools this is appearing as:
o.flash.success("Some string")
(nb. o instead of shell because it's minified)
I noticed the same thing in IE.
Why does it display the string with double quotes when single quotes were used?
Related
This question already has answers here:
Need to escape non-ASCII characters in JavaScript
(4 answers)
Javascript, convert unicode string to Javascript escape?
(6 answers)
Closed 1 year ago.
Just from a browser developer console or Node.js repl, what's an easy way to transcribe a string as its unicode representation? For example I can input '\u0048\u0065\u006C\u006C\u006F' and the repl will show me 'Hello'
> '\u0048\u0065\u006C\u006C\u006F'
"Hello"
How can I reverse this?
> something('Hello')
"\u0048\u0065\u006C\u006C\u006F"
For example. I hope there are some convenient built-ins or browser console/repl support.
This question already has answers here:
Allow "/" forward slash in regular expression
(2 answers)
Closed 3 years ago.
Visual Studio Code is reporting a syntax issue with this regex in javascript:
let regex;
regex = /^https:\/\/[^\/]+/[A-Za-z]+-[\d\D]{4}-Report$/g;
Specifically, squiggly red underline beneath \d and {
Before I start ripping out extensions, does anyone see anything obvious?
You have a missing escaping backslash here:
/^https:\/\/[^\/]+/[A-Za-z]+-[\d\D]{4}-Report$/g
^
So it should be:
/^https:\/\/[^\/]+\/[A-Za-z]+-[\d\D]{4}-Report$/g
This question already has answers here:
What does this symbol mean in JavaScript?
(1 answer)
What does this `…${…}…` code in the node docs mean? [duplicate]
(1 answer)
Closed 5 years ago.
I'm a bit of a beginner still and keep coming across this in code:
${Math.round(newProps.percent)}% surrounded by backticks
or
${currentBillingStartDate} surrounded by backticks and not using the percent.
I'd like to understand when it should be used and why.
The percent sign is just a character that is meant to be interpolated with the expression inside the ${variable}. The result would be a string that looks like "55%"
This question already has answers here:
What is the JavaScript string newline character?
(15 answers)
Closed 6 years ago.
Can someone please explain to me what is a Line Terminator? I have trouble searching it online. It may be slightly irrelevant to the question but I would just like to know.
A line terminator is OS specific. This doesn't have anything to do with JavaScript. On windows a line is terminated by the control character sequence \r\n, On UNIX like systems, it is \n.
Recall that control characters aren't printable characters, so the \r and \n is conceptual, but usually they're put in string literals to represent the control character.
This question already has answers here:
Are double and single quotes interchangeable in JavaScript?
(23 answers)
Closed 9 years ago.
If there is an difference, if I use " or ' in javascript or html?
Till now I was coding in php and java only and now I don't know, if I can use ' only or do I have to use ".
I know a bit stupid question, but it makes me confuse, since I am used to ' syntex instead of ".
In JavaScript and in HTML, choosing single vs. double quotes is style preference–there is no functional difference like there is in PHP. Commas in JavaScript serve the same purpose as in PHP plus they can be used in expressions.