Linked Questions

3143 votes
47 answers
3.1m views

Is there a universal JavaScript function that checks that a variable has a value and ensures that it's not undefined or null? I've got this code, but I'm not sure if it covers all cases: function ...
130 votes
5 answers
609k views

I know this is really basic, but I am new to javascript and can't find an answer anywhere. How can I check if a string is empty?
Andrew's user avatar
  • 241k
18 votes
1 answer
13k views

Help me pls if(value == ""){ // do anything } but I need to check space " " (2,3,... space is include) is the same way of empty String ps. sorry in my English
-4 votes
3 answers
56k views

I am trying to make a factorial calculator. How can I check if the input is empty or not? I tried 'null'. But it didn't work or I couldn't use it properly. sorry for the stupid question. I am newbie ...
9 votes
0 answers
20k views

[Use-case: portable Lo-Dash code] I've been looking for an elegant Lo-Dash empty-string validator in our nodeJS projects for some time now, because _.isEmpty() only handles Arrays and Objects. So I ...
sneeuwitje's user avatar
3 votes
2 answers
11k views

I have a variable that can be either empty, number or text. I like to find only empty one. But the following codes using .length returned null for 0 number, though it returned 1 for "0" ...
5 votes
1 answer
624 views

I have var names = []; and want push there some string only if it's not empty. Is there way make it with some shorthand method in js?) That i have now. if ("" != opportunityName) { names....
-1 votes
1 answer
510 views

Hi there everyone how can I detect if the user input has just empty spaces? Detect this: input = ' '; input = ' '; etc... DO NOT detect this: input 'hi there'; I just want to detect if ...
pixie123's user avatar
  • 989
0 votes
1 answer
266 views

I am pretty new to jQuery so I have a problem with this. I am trying to check if input is empty by jQuery. I have this script: $('#submit').click(function(){ if($.trim($('#username').val()) == ...
-1 votes
1 answer
106 views

I`m building messaging app and I need regex or some other way to validate message that user is about to send. Message must contain at least one character, expect for space. const valid = *regex* ...
-5 votes
1 answer
93 views

I am trying to reduce the length of the text that I have requested from the API with the 'slice' method. but it is throwing an error of 'Cannot read property 'slice' of undefined.
1 vote
0 answers
94 views

I'm trying to create a ternary expression that decides what to do if the user enters a name or not. If the user enters a name — like 'Jane' — use string interpolation to log Hello, Jane! to the ...
0 votes
0 answers
18 views

super beginner here: I having trouble figuring out how to correctly use this conditional statement for a placeholder. For some reason, it only executes one condition after clicking on submit (in this ...
5643 votes
47 answers
2.2m views

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....
3889 votes
41 answers
4.4m views

After an AJAX request, sometimes my application may return an empty object, like: var a = {}; How can I check whether that's the case?
falmp's user avatar
  • 39.3k

15 30 50 per page
1
2 3 4 5 6