2,525,024 questions
12253
votes
51
answers
13.6m
views
How can I remove a specific item from an array in JavaScript?
How do I remove a specific value from an array? Something like:
array.remove(value);
Constraints: I have to use core JavaScript. Frameworks are not allowed.
8741
votes
67
answers
3.3m
views
How do I check if an element is hidden in jQuery?
How do I toggle the visibility of an element using .hide(), .show(), or .toggle()?
How do I test if an element is visible or hidden?
8540
votes
32
answers
1.2m
views
What does "use strict" do in JavaScript, and what is the reasoning behind it?
Recently, I ran some of my JavaScript code through Crockford's JSLint, and it gave the following error:
Problem at line 1 character 1: Missing "use strict" statement.
Doing some searching, ...
7694
votes
58
answers
8.2m
views
How do I redirect to another webpage?
How can I redirect the user from one page to another using jQuery or pure JavaScript?
7671
votes
42
answers
1.2m
views
var functionName = function() {} vs function functionName() {}
I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent.
The previous developer used two ways ...
7609
votes
86
answers
1.6m
views
How do JavaScript closures work?
How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves?
I ...
7585
votes
40
answers
3.4m
views
How do I remove a property from a JavaScript object?
Given an object:
let myObject = {
"ircEvent": "PRIVMSG",
"method": "newURI",
"regex": "^http://.*"
};
How do I remove the property ...
7403
votes
3
answers
8.4m
views
How to check whether a string contains a substring in JavaScript?
Usually I would expect a String.contains() method, but there doesn't seem to be one.
What is a reasonable way to check for this?
6743
votes
44
answers
2.2m
views
How do I return the response from an asynchronous call?
How do I return the response/result from a function foo that makes an asynchronous request?
I am trying to return the value from the callback, as well as assigning the result to a local variable ...
6408
votes
38
answers
2.4m
views
What is the difference between "let" and "var"?
ECMAScript 6 introduced the let declaration keyword.
I've heard that it's described as a local variable, but I'm still not quite sure how it behaves differently than the var keyword.
What are the ...
6381
votes
72
answers
4.5m
views
How do I include a JavaScript file in another JavaScript file?
How do I include a JavaScript file inside another JavaScript file, similar to @import in CSS?
5809
votes
41
answers
5.5m
views
Loop (for each) over an array in JavaScript
How can I loop through all the entries in an array using JavaScript?
5643
votes
47
answers
2.2m
views
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....
5517
votes
50
answers
4.6m
views
How do I replace all occurrences of a string?
Given a string:
string = "Test abc test test abc test test test abc test test abc";
This seems to only remove the first occurrence of abc in the string above:
string = string.replace('abc', ...
5494
votes
77
answers
3.3m
views
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 ...