Most Popular
1500 questions
5272
votes
73 answers
How do I create a GUID / UUID?
How do I create GUIDs (globally-unique identifiers) in JavaScript? The GUID / UUID should be at least 32 characters and should stay in the ASCII range to avoid trouble when passing them around.
I'm not sure what routines are available on all…

Jason Cohen
- 81,399
- 26
- 107
- 114
5251
votes
37 answers
How do I add an empty directory to a Git repository?
How do I add an empty directory (that contains no files) to a Git repository?

Laurie Young
- 136,234
- 13
- 47
- 54
5249
votes
27 answers
Accessing the index in 'for' loops
How do I access the index while iterating over a sequence with a for loop?
xs = [8, 23, 45]
for x in xs:
print("item #{} = {}".format(index, x))
Desired output:
item #1 = 8
item #2 = 23
item #3 = 45

Joan Venge
- 315,713
- 212
- 479
- 689
5196
votes
45 answers
How do I squash my last N commits together?
How do I squash my last N commits together into one commit?

markdorison
- 139,374
- 27
- 55
- 71
5192
votes
33 answers
How do I make a flat list out of a list of lists?
I have a list of lists like
[
[1, 2, 3],
[4, 5, 6],
[7],
[8, 9]
]
How can I flatten it to get [1, 2, 3, 4, 5, 6, 7, 8, 9]?
If your list of lists comes from a nested list comprehension, the problem can be solved more simply/directly…

Emma
- 52,713
- 4
- 19
- 10
5190
votes
28 answers
What is the difference between "INNER JOIN" and "OUTER JOIN"?
Also, how do LEFT OUTER JOIN, RIGHT OUTER JOIN, and FULL OUTER JOIN fit in?

Chris de Vries
- 56,777
- 5
- 32
- 27
5175
votes
13 answers
How do I exit Vim?
I am stuck and cannot escape. It says:
type :quit to quit VIM
But when I type that it simply appears in the object body.

jclancy
- 49,598
- 5
- 30
- 34
5169
votes
67 answers
What is the most efficient way to deep clone an object in JavaScript?
What is the most efficient way to clone a JavaScript object? I've seen obj = eval(uneval(o)); being used, but that's non-standard and only supported by Firefox. I've done things like obj = JSON.parse(JSON.stringify(o)); but question the efficiency. …

jschrab
- 11,035
- 4
- 20
- 17
5155
votes
20 answers
What's the difference between tilde(~) and caret(^) in package.json?
After I upgraded to the latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix.
Why are these changes made in npm?
What is the difference…

Fizer Khan
- 88,237
- 28
- 143
- 153
5148
votes
68 answers
How do I check whether a checkbox is checked in jQuery?
I need to check the checked property of a checkbox and perform an action based on the checked property using jQuery.
For example, if the age checkbox is checked, then I need to show a textbox to enter age, else hide the textbox.
But the following…

Prasad
- 58,881
- 64
- 151
- 199
5115
votes
102 answers
How do I make the first letter of a string uppercase in JavaScript?
How do I make the first character of a string uppercase if it's a letter, but not change the case of any of the other letters?
For example:
"this is a test" → "This is a test"
"the Eiffel Tower" → "The Eiffel Tower"
"/index.html" → "/index.html"

Robert Wills
- 51,811
- 3
- 18
- 6
5054
votes
25 answers
Reference Guide: What does this symbol mean in PHP? (PHP Syntax)
What is this?
This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this list.
Why is this?
It used to be hard to find questions…

Gordon
- 312,688
- 75
- 539
- 559
5037
votes
131 answers
How can I horizontally center an element?
How can I horizontally center a
within another
using CSS?
Foo foo

Lukas
- 9,476
- 4
- 20
- 14
4912
votes
31 answers
What is the difference between a URI, a URL, and a URN?
What is the difference between a URL, a URI, and a URN?

Sean McMains
- 57,907
- 13
- 47
- 54
4850
votes
62 answers
How do I check if an array includes a value in JavaScript?
What is the most concise and efficient way to find out if a JavaScript array contains a value?
This is the only way I know to do it:
function contains(a, obj) {
for (var i = 0; i < a.length; i++) {
if (a[i] === obj) {
return…

brad
- 73,826
- 21
- 73
- 85