Home  >  Article  >  Web Front-end  >  The correct way to determine undefined type in JavaScript

The correct way to determine undefined type in JavaScript

PHPz
PHPzOriginal
2016-05-16 15:52:081327browse

This article mainly introduces the correct way to determine the undefined type in JavaScript. I believe many students will use the wrong method when encountering this problem. The correct method is also very simple. Friends in need can refer to it

The code is as follows:

  if (reValue== undefined){
    alert("undefined");
    }

I found that I couldn’t determine it. Finally, I checked the information and needed to use the typeof

method:

The code is as follows:

if (typeof(reValue) == "undefined") { 
   alert("undefined"); 
}

typeof returns a string, there are six possibilities: "number", "string", "boolean", "object", "function", "undefined"

More For more related tutorials, please visit JavaScript Basics Tutorial

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