Home > Web Front-end > JS Tutorial > body text

The correct way to determine undefined type in JavaScript

PHPz
Release: 2018-10-12 16:33:53
Original
1327 people have browsed it

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");
    }
Copy after login

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"); 
}
Copy after login

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

More For more related tutorials, please visit JavaScript Basics Tutorial

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!