Standard data type partitioning:
Basic type:
Number (numeric), string (string), Undefined, Boolean (Boolean), null (NULL object)
The biggest difference between an empty object and a non-empty object is that you cannot perform property operations
Object type (composite type):
Object (Objects)
There is no function in the object type and the function does not belong to the data;
typeof Operator:
is the data type used to detect variables, for values or variables. typeof The operator returns the string as follows. The code is as follows
var nub = ten; Console.log (typeof nub); Number number /* numbers from negative infinity to positive infinity, and Nan (not a digit) */
var str = "Asdsadsad"; String string Console.log (typeof str);/* any string of characters enclosed in quotation marks are strings */
var is = true; Boolean Boolean value Console.log (typeof is);/* true and false*/
var arr = []; Object Object Console.log (typeof arr); Console.log (null = = arr);//Note empty array is not equal to null object var obj = null; Object Console.log (typeof obj); var el = document; Object Object Console.log (typeof el);/* objects: array, NULL, Element object, Object*/var u;//undefined undefined Console.log (typeof u); var fn = function () {//function alert (1);} Console.log (typeof fn), function fn2 () {//function alert (2);} Console.log (typeof fn2);
The data types in typeof are divided into:
- Number
- String
- Undefined
- Boolean
- Object
- function
JS data type Getting started with typeof operator