Most Popular

1500 questions
5655
votes
48 answers

Which equals operator (== vs ===) should be used in JavaScript comparisons?

I'm using JSLint to go through JavaScript, and it's returning many suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing idSele_UNVEHtype.value.length == 0 inside of an if statement. Is there a…
bcasp
  • 57,417
  • 4
  • 18
  • 14
5522
votes
11 answers

The definitive guide to form-based website authentication

Moderator note: This question is not a good fit for our question and answer format with the topicality rules which currently apply for Stack Overflow. We normally use a "historical lock" for such questions where the content still has value.…
Michiel de Mare
  • 41,284
  • 28
  • 101
  • 134
5398
votes
17 answers

What is the maximum length of a URL in different browsers?

What is the maximum length of a URL in different browsers? Does it differ among browsers? Is a maximum URL length part of the HTTP specification?
Sander Versluys
  • 70,017
  • 23
  • 81
  • 90
5363
votes
40 answers

For-each over an array in JavaScript

How can I loop through all the entries in an array using JavaScript?
Dante1986
  • 55,693
  • 12
  • 36
  • 53
5352
votes
32 answers

How to change the URI (URL) for a remote Git repository?

I have a repo (origin) on a USB key that I cloned on my hard drive (local). I moved "origin" to a NAS and successfully tested cloning it from here. I would like to know if I can change the URI of "origin" in the settings of "local" so it will now…
e-satis
  • 551,433
  • 107
  • 289
  • 326
5321
votes
35 answers

How can I reset or revert a file to a specific revision?

I have made some changes to a file which has been committed a few times as part of a group of files, but now want to reset/revert the changes on it back to a previous version. I have done a git log along with a git diff to find the revision I need,…
Hates_
  • 63,147
  • 6
  • 30
  • 37
5308
votes
102 answers

How can I validate an email address in JavaScript?

I'd like to check if the user input is an email address in JavaScript, before sending it to a server or attempting to send an email to it, to prevent the most basic mistyping. How could I achieve this?
pix0r
  • 30,913
  • 18
  • 84
  • 102
5226
votes
43 answers

What is a plain English explanation of "Big O" notation?

I'd prefer as little formal definition as possible and simple mathematics.
5200
votes
29 answers

How can I safely create a nested directory?

What is the most elegant way to check if the directory a file is going to be written to exists, and if not, create the directory using Python? Here is what I tried: import os file_path = "/my/directory/filename.txt" directory =…
Parand
  • 97,666
  • 45
  • 150
  • 182
5198
votes
36 answers

How do I resolve merge conflicts in a Git repository?

I want to resolve merge conflicts in my Git repository. How can I do that?
Spoike
  • 116,468
  • 43
  • 136
  • 157
5177
votes
79 answers

How to replace all occurrences of a string in JavaScript

I have this string in my JavaScript code: "Test abc test test abc test test test abc test test abc" Doing: str = str.replace('abc', ''); Seems to only remove the first occurrence of abc in the string above. How can I replace all occurrences of it?
Ali
  • 249,782
  • 257
  • 562
  • 750
5173
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
  • 19
  • 17
5171
votes
17 answers

How do I push a new local branch to a remote Git repository and track it too?

I want to be able to do the following: Create a local branch based on some other (remote or local) branch (via git branch or git checkout -b) Push the local branch to the remote repository (publish), but make it trackable so git pull and git push…
Roni Yaniv
  • 53,606
  • 5
  • 18
  • 16
5068
votes
27 answers

What is the difference between "INNER JOIN" and "OUTER JOIN"?

Also how do LEFT JOIN, RIGHT JOIN and FULL JOIN fit in?
Chris de Vries
  • 55,523
  • 5
  • 30
  • 27
5001
votes
66 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
  • 57,753
  • 61
  • 145
  • 199