Pre-recorded question

Question #6
How to check if a JavaScript string is empty or contains only spaces?
Answer

To check if a JavaScript string is empty or contains only spaces, trim the content and check if the string is empty:

var str='  ';
if (!str.trim()) {
    // Do something, the string is empty or contains only spaces
}

5 events in history
Answer by Alphonsio 04/27/2020 at 05:38:29 PM

To check if a JavaScript string is empty or contains only spaces, trim the content and check if the string is empty:

var str='  ';
if (!str.trim()) {
    // Do something, the string is empty or contains only spaces
}

Answer by Alphonsio 04/27/2020 at 05:37:59 PM

To check if a JavaScript string is empty or contains only space, trim the content and check if the string is empty:

var str='  ';
if (!str.trim()) {
    // Do something, the string is empty or contains only spaces
}

Answer by Alphonsio 04/27/2020 at 05:37:27 PM

To check if a JavaScript string is empty or contains only space, trim the content and check if the string is empty:

var str='  ';
if (!str.trim()) {
    // Do something, the string is empty or contains only spaces
}

Answer by Alphonsio 04/27/2020 at 05:36:11 PM

To check if a JavaScript string is empty or contains only space, trim the content and check if the string is empty:

var str='  ';
if (!str.trim()) {
    // Do something, the string is empty or contains only spaces
}

Question by Alphonsio 04/27/2020 at 04:59:13 PM
How to check if a JavaScript string is empty or contains only spaces?
# ID Query URL Count

Icons proudly provided by Friconix.