Home >Web Front-end >JS Tutorial >How to determine whether a character is empty in javascript

How to determine whether a character is empty in javascript

coldplay.xixi
coldplay.xixiOriginal
2021-04-09 11:10:553911browse

Javascript method to determine whether a character is empty: first determine whether a character is empty, the code is [if(typeof res== "undefined" || res== null || res== "")]; Then call it through js.

How to determine whether a character is empty in javascript

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.

Javascript method to determine whether a character is empty:

js code:

//判断字符是否为空的方法
function IsEmpty(res){
    if(typeof res== "undefined" || res== null || res== ""){
        return true;
    }else{
        return false;
    }
}

js call:

if (!IsEmpty(value)) {
    alert(value);
}

Related free learning recommendations: javascript(Video)

The above is the detailed content of How to determine whether a character is empty in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn