Home > Article > Web Front-end > Determine whether the input is empty and obtain the JS code of the input type_javascript skills
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: