zoukankan      html  css  js  c++  java
  • 【jQuery api】 $.type(obj)

    用来获取JavaScript数据类型[[Class]]的对象

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4   <script src="http://code.jquery.com/jquery-latest.js"></script>
     5 </head>
     6 <body>
     7   Is it a RegExp? <b></b>
     8 <script>$("b").append( "" + jQuery.type(/test/) );</script>
     9  
    10 </body>
    11 </html>
    1 Is it a RegExp? regexp
    • 如果对象是undefined或null,则返回相应的“undefined”或“null”。
      • jQuery.type( undefined ) === "undefined"
      • jQuery.type() === "undefined"
      • jQuery.type( window.notDefined ) === "undefined"
      • jQuery.type( null ) === "null"
    • 如果对象有一个内部的[[Class]]和一个浏览器的内置对象的 [[Class]] 相同,我们返回相应的 [[Class]] 名字。
    • jQuery.type( true ) === "boolean"
      • jQuery.type( 3 ) === "number"
      • jQuery.type( "test" ) === "string"
      • jQuery.type( function(){} ) === "function"
      • jQuery.type( [] ) === "array"
      • jQuery.type( new Date() ) === "date"
      • jQuery.type( new Error() ) === "error" // as of jQuery 1.9
      • jQuery.type( /test/ ) === "regexp"
      • 其他一切都将返回它的类型“object”。
  • 相关阅读:
    vue中使用 canvas给页面添加水印
    c++ get keyboard event
    sublime text c++ makefile
    dddd
    songwenxin
    wechat
    ddd
    log
    v3
    xiaoxiaole
  • 原文地址:https://www.cnblogs.com/dream-to-pku/p/5973639.html
Copyright © 2011-2022 走看看