Linked Questions
19 questions linked to/from JavaScript: Simple way to check if variable is equal to one of two or more values?
5002
votes
63
answers
3.7m
views
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++...
2
votes
1
answer
826
views
shorthand for conditions like (x === y) || (x === z)? [duplicate]
I want to make my condition easier to read and wandering if it is possible to simplify this Scenario:
if((x === y)||(x === z)){...}
//and this one:
x = (x === y) || (x === z)? ... : ...;
//To ...
-4
votes
2
answers
201
views
How to add multiple CSS property in JavaScript If statement? [duplicate]
I have this script
$(document).ready(function() {
setInterval(function() {
if ($('#myfooter').css('visibility') == 'hidden'){
document.location.href = "...
-1
votes
2
answers
107
views
The IF statement got it wrong? [duplicate]
Hey I'm a beginner at javascript, and I've come across this issue. It seems like the IF statement recognizes the variable as something it isn't. I think it has something to do with the OR operator?
...
0
votes
1
answer
99
views
Conditional wrong when trying to match strings [duplicate]
I have code that gets the users locale and store it in a variable. I then have a conditional that checks if the locale matches a specific value - see the picture below:
Above you can see the value of ...
0
votes
1
answer
83
views
Is there a more concise way to set up a conditional statement to execute for an arbitrary set of values of a variable? [duplicate]
Is there a more efficient/ concise/ eloquent way to write this:
else if ((aInd === 3)||(aInd === 7)||(aInd === 9)||(aInd === 19)
letter = alphabet[aInd + 1].toUpperCase();
Is there any valid ...
0
votes
0
answers
29
views
Why won't my JavaScript account system code work or run? [duplicate]
I'm trying to create a JS account system with HTML forms, but my script either won't run, or doesn't work. I've looked through the code many times and make changes, but nothing ever works. Can someone ...
2101
votes
28
answers
1.1m
views
Why is using "for...in" for array iteration a bad idea?
I've been told not to use for...in with arrays in JavaScript. Why not?
218
votes
16
answers
226k
views
Check variable equality against a list of values
I'm checking a variable, say foo, for equality to a number of values. For example,
if( foo == 1 || foo == 3 || foo == 12 ) {
// ...
}
The point is that it is rather much code for such a trivial ...
12
votes
4
answers
5k
views
Most succinct way to determine if a variable equals a value from a 'list' of values
If I have a variable in C# that needs to be checked to determine if it is equal to one of a set of variables, what is the best way to do this?
I'm not looking for a solution that stores the set in an ...
44
votes
0
answers
5k
views
What does `!!~` mean in javascript? [duplicate]
Possible Duplicate:
What does tilde (~) preceding jQuery object do?
I found a strange !!~ in the code when reading: https://github.com/LearnBoost/mongoose/blob/master/lib/document.js#L678
...
0
votes
3
answers
2k
views
How to compare if multiple strings are not found in a statement from input variable?
I would like to print "Error" message every time a word is not found in a variable from prompt input, it does work with single comparison like for example if (variable!== "word"). But whenever i try ...
0
votes
2
answers
1k
views
value is always empty inside ternary operator statement
I am using ReactJS and a library called React-Table for an online gaming site.
In the table, I have one column cell that could potentially be empty or NULL.
So, if that column cell is null or empty or ...
0
votes
1
answer
354
views
Javascript find with multiple conditions with includes fails
I have the following array
let registrations = [
{user:1, reg_on:'12/02/2009'},
{user:10, reg_on:'11/02/2009'},
{user:5, reg_on:'11/02/2109'},
///others
]
So now am trying to find one ...
-3
votes
1
answer
842
views
If statement with (a == b && c == d || e) || a != b) [closed]
I'm trying to get a value in a dropdown to not show if another value is selected.
Basically saying if Internal is showing, don't show Record_type_wf or record_type_vr
But when adding in the or ...