typeof Operator returns a string representing the data type of the expression . Possible strings are :"number"、"string"、"boolean"、"object"、"function" and "undefined".

  • typeof The operands of define uninitialized , Back to you "undefined".
  • The operands are numbers typeof(x) = "number"
  • character string typeof(x) = "string"
  • Boolean value typeof(x) = "boolean"
  • object , Array and null typeof(x) = "object"
  • function typeof(x) = "function"

typeof In two cases it will return "undefined": When a variable is not declared , And the value of a variable undefined When .

for example :

if(typeof (document.all("selection").length) == "undefined")
alert("length No definition ");
alert(typeof (123));//typeof(123) return "number"
alert(typeof ("123"));//typeof("123") return "string"

js Medium judgement undefined More related articles on this topic

  1. jquery ajax Which return types are supported in and js A common way to judge a type in ?

    1 jquery ajax Which return types are supported in JQuery in ,AJAX There are three ways to do it :$.ajax() , $.post , $.get(). Expected data type returned by the server . If you don't specify ,jQuery Will self ...

  2. js Several methods to determine the type of object in

    We know ,JavaScript The operators that detect object types in are :typeof.instanceof, There are also objects constructor attribute : 1) typeof Operator typeof It's a unary operator , The return result is a ...

  3. [JS]js Function to determine the type of variable in typeof Summary of usage of [ turn ]

    1. effect : typeof Operator returns a string representing the data type of the expression .  Possible strings are :"number"."string"."boolean&q ...

  4. js To determine the specific type of the object

    You may know that js You can use typeof To judge . Look at the following <script> alert(typeof 1);//number alert(typeof "2" ...

  5. html5 -js Judge undefined type

    js Judge undefined type Use today showModalDialog Open the page , On return value . When you click the close button on the open page or directly click close on the browser, the return value is undefined So make your own smart judgment var reVal ...

  6. js Judge undefined type ,undefined,null,NaN The difference between

    js Judge undefined type Use today showModalDialog Open the page , On return value . When you click the close button on the open page or directly click close on the browser, the return value is undefined   So make your own smart judgment        ...

  7. JS Five ways to judge the type of variable in

    5 Basic data types :undefined.null.boolean.unmber.string Complex data type :object. object:array.function.date etc. Method 1 : Use typeo ...

  8. JS Several ways to judge the type of variable in

    Article arrangement and transportation , The source is unknown , In case of infringement , Please contact the ~   Data type judgment and data type conversion code tool stay JS in , Yes 5 Two basic data types and 1 Complex data types , The basic data types are :Undefined, Null, Boo ...

  9. JS The judgment of variable type in

    summary :1. Generally simple to use typeof or instanceof testing ( These two tests are not completely accurate )          2. Completely accurate use of Native js Medium  Object.prototype.toStri ...

Random recommendation

  1. Linux command —— Simple summary

    1. Change the file owner   command : chown [-cfhvR] [--help] [--version] user[:group] file...  function : Change the owner of a file or folder   Parameter format :  ...

  2. Lotus Development of Lotus Notes Verification of the middle domain

    One : Introduce       Lotus There are mainly the following types of domains in : Text , date / Time , Dialog list , Check box , Radio button ,RTF wait .Lotus There are many formulas for the verification of middle domain ,lotusscript,javascript etc. ...

  3. RSA Encryption, decryption and digital signature Java Realization -- turn

    RSA The public key encryption algorithm is 1977 Ronald · Levister (Ron Rivest). ADI · Samore (Adi Shamir) And Leonard · Adelman (Leonard Adleman) Put forward together . All three of them were at MIT ...

  4. 【JQ Growth notes 】jQuery Validate Validation plug-ins

    validate It's a very good jq plug-in unit , Provides powerful verification capabilities , Make client form validation easier , At the same time, there are a lot of customization options , Meet the needs of the application . The plug-in comes with a useful set of verification methods , Include URL And email verification , Same as ...

  5. Delphi Hide process

    interface function MyHideProcess: Boolean; implementation uses Windows, Classes, AclAPI, accCtrl; ty ...

  6. Linux Shared library zlog journal

    [ global] strict init = false buffer min = buffer max = 2MB rotate lock file= /tmp/zlog.lock [format ...

  7. spring MVC The mode intercepts the input and output parameters of all entry methods

    import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.serializer.SerializerFeature; im ...

  8. java in i = i++ problem

    I came across a question today java The problem of autoincrement operator in , It's about the stack , I think it's interesting to record it . int i=0;      i=i++;      result i How much is the ?      This is a question that is often mentioned , Answer 1 ...

  9. unbuntu 14.04 Install Sogou ime

    http://blog.csdn.net/leijiezhang/article/details/53707181

  10. Reprint someone else's DLL DEll Research

    Yesterday, , I made it up DLL and EXE To test ,exe adopt lib Static binding dll, To call its export class , When change DLL The structure of the exported class in (eg. The order of member variables, etc ), New release DLL Instead of recompiling EXE, It's going to make a mistake ...