Arrays are often used in js, such as multiple inputs with the same name. If they are generated dynamically, you need to determine whether they are an array when submitting.
if( != "undefined" ) {} This usage is incorrect.
The correct thing is if( typeof() != "undefined" ) {}
or if( !isNaN() ) {}
The operation number of typeof is undefined, and the return is "undefined".
The number of operations is a number typeof(x) = "number"
string typeof(x) = "string"
boolean typeof(x) = "boolean"
Object, array and null typeof(x) = "object"
function typeof(x) = "function"
The typeof operator returns a string that represents the data type of the expression.
Possible strings are: "number", "string", "boolean", "object", "function" and "undefined".
like:
alert(typeof (123));//typeof(123) returns "number"
alert(typeof ("123"));//typeof("123") returns "string"
typeof operator
Returns a string that represents the data type of the expression.
typeof[()expression[]] ;
The expression parameter is any expression that needs to look for type information.
illustrate
The typeof operator returns the type information as a string. There are six possibilities for typeof return value: "number," "string," "boolean," "object," "function," and "undefined."
The parentheses in the typeof syntax are optional.
if( != "undefined" ) {} This usage is incorrect.
The correct thing is if( typeof() != "undefined" ) {}
or if( !isNaN() ) {}
The operation number of typeof is undefined, and the return is "undefined".
The number of operations is a number typeof(x) = "number"
string typeof(x) = "string"
boolean typeof(x) = "boolean"
Object, array and null typeof(x) = "object"
function typeof(x) = "function"
The typeof operator returns a string that represents the data type of the expression.
Possible strings are: "number", "string", "boolean", "object", "function" and "undefined".
like:
alert(typeof (123));//typeof(123) returns "number"
alert(typeof ("123"));//typeof("123") returns "string"
typeof operator
Returns a string that represents the data type of the expression.
typeof[()expression[]] ;
The expression parameter is any expression that needs to look for type information.
illustrate
The typeof operator returns the type information as a string. There are six possibilities for typeof return value: "number," "string," "boolean," "object," "function," and "undefined."
The parentheses in the typeof syntax are optional.
12Next pageRead the full text