Home  >  Article  >  Web Front-end  >  Determine whether the input is empty and obtain the JS code of the input type_javascript skills

Determine whether the input is empty and obtain the JS code of the input type_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:18:12669browse

Use typeof algorithm

The operand of typeof is undefined, and the returned value is "undefined".

The following defines x as the operand:

There are five situations;

The operand is a number, typeof(x) returns "number";

String typeof(x) returns "string";

Boolean value typeof(x) returns "boolean";

Object, array, null: typeof(x) returns "object";

The function typeof(x) returns "function".

For example:

Copy code The code is as follows:


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