This question already has answers here:
Using explicitly numbered repetition instead of question mark, star and plus
(4 answers)
Reference - What does this regex mean?
(1 answer)
Closed 4 years ago.
Is there any difference between the regular expressions:-
/^[1-9][0-9]+$/
and
/^[1-9]{1}[0-9]+$/
They both seem to give the same result. Which convention is better,because in many examples I can see the use of {1}, but feel it is quite useless, am I right?
Related
This question already has answers here:
What does this symbol mean in JavaScript?
(1 answer)
What do these JavaScript bitwise operators do?
(3 answers)
Closed 27 days ago.
What is the difference between a Right Shift assignment and unsigned Right Shift assignment?
I visited some sites like MWD w3school and etc but I could notice that. also, check the answers in the stack overflow but in want to know to compare these symbols.
This question already has answers here:
How do I split a string with multiple separators in JavaScript?
(25 answers)
Closed 3 years ago.
I have a string "str1+str2-str3*str4".
I want to split it so I get an array
['str1','+','str2','-','str3','*','str4'].
Could someone help provide a solution?
If JS split lets capture groups become elements, then this should work
/([-+*\/])/
if not, I suggest using a regular find all type thing
using this
/([-+*\/]|[^-+*\/]+)/
otherwise, I'll just delete this.
This question already has answers here:
What does ## ("at at") mean in ES6 JavaScript?
(1 answer)
JS variable starting with "#"
(4 answers)
Closed 4 years ago.
When I look through the MDN docs I sometimes notice ##. For example the Set documentation has links to get Set[##species] and Set.prototype[##iterator]()
What does ## mean?
(Also how do you say it? "AT-AT" would make for a great Star Wars reference)
This question already has answers here:
What does the "|" (single pipe) do in JavaScript?
(5 answers)
What is this asm style "x | 0" some javascript programmers are now using?
(4 answers)
Closed 7 years ago.
I have been looking into asm.js to use for a project recently, and I noticed that very often the asm.js compiled code will end a statement with |0;, even seemingly redundantly as in the statement i = i|0;
This is not something I have encountered in Javascript code before. What is it for?
EDIT
I don't believe this is duplicate. I know what a bitwise or is. I am specifically asking here why one might use it to or with a 0 before assignment. What purpose does that serve?
Convert to integer and apply a bitwise or with 0. Basically a short form of Math.floor().
This question already has answers here:
Negative lookbehind equivalent in JavaScript
(11 answers)
Closed 7 years ago.
I've seen a few answers that deal with this question but was unable to get them to work.
What is a regex that would match "LOGGED_IN" but not match "NOT_LOGGED_IN"?
^LOGGED_IN$ is first to come to mind