`
Blackbaby
  • 浏览: 185036 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

JavaScript:The Class of an Object

阅读更多
function is(type, obj) { 
    var clas = Object.prototype.toString.call(obj).slice(8, -1); 
    return obj !== undefined && obj !== null && clas === type; 
} 
 
is('String', 'test'); // true 
is('String', new String('test')); // true 

 

 

   In the above example, Object.prototype.toString gets called with the value of this being set to the object whose [[Class]] value should be retrieved.

分享到:
评论

相关推荐

    javascript.the.definitive.guide.5th.2006(英文版)

    This book is both an example-driven programmer's guide and a keep-on-your-desk reference, with new chapters that explain everything you need to know to get the most out of JavaScript, including: ...

    Sortable前端框架

    * put: `true|false|["foo", "bar"]|function` — whether elements can be added from other lists, or an array of group names from which elements can be taken. * revertClone: `boolean` — revert cloned ...

    JavaScript in 10 Minutes

    2. **Java Classes and Interfaces**: Although the title mentions "Java classes and interfaces," this section likely discusses JavaScript's approach to object-oriented programming, including class-like ...

    Java_for_the_Web_with_Servlets

    - **`GenericServlet` Wrapper Class**: This abstract class provides a convenient implementation of the `Servlet` interface and can be extended to create custom servlets. - **Thread-Safe Servlets**: ...

    JavaScript权威指南(第五版).chm

    This book is both an example-driven programmer's guide and a keep-on-your-desk reference, with new chapters that explain everything you need to know to get the most out of JavaScript, including: ...

    C++调用JavaScript

    In any case, it is possible to make a control for the JavaScript object inside an HTML page by using a traditional COM approach. This article describes the class CWebPage that allows you to do it and...

    OO4O(Oracle Objects for OLE C++ Class Library)

    Oracle Objects for ... OO4O consists of an in-process COM Automation Server, the C++ class library, and the Oracle Data Control. Relationships shows the high-level relationship between OO4O components.

    JavaScript权威指南第五版【新】(犀牛书)

    This book is both an example-driven programmer's guide and a keep-on-your-desk reference, with new chapters that explain everything you need to know to get the most out of JavaScript, including: ...

    The Dart Programming Language

    Dart is a class-based, object-oriented language that simplifies the development of structured modern apps, scales from small scripts to large applications, and can be compiled to JavaScript for use in...

    Smart Mobile Studio Enterprise v2.0 Build 723 Cracked

    You have reached the home of Smart Mobile Studio, a very exciting project that allows you to write ordinary Pascal in the flavour made famous by Delphi and Free Pascal, but generate feature rich, ...

    jdk1.8.docx

    5. **Optional Class**: The Optional class is a container object that may or may not hold a non-null value. It helps prevent null pointer exceptions by encouraging developers to explicitly handle the ...

    The.Dart.Programming.Language.03219277

    Dart is a class-based, object-oriented language that simplifies the development of structured modern apps, scales from small scripts to large applications, and can be compiled to JavaScript for use in...

    Modelling and Generating Ajax Applications A Model-Driven Approach

    - **Class Diagrams**: Define the structure of the system and its components. - **Sequence Diagrams**: Illustrate the interactions between components, especially focusing on event handling and ...

    IntraWeb v14.0.23 Ultimate for RAD Studio XE-XE5 (x32+x64)

    A Slim Reader/Writer lock object is used in TIWStandAloneServer and TIWServerInternalFiles instead of TMultiReadExclusiveWriteSynchronizer object. This new lock is available under Windows Vista and up...

    外文翻译 stus MVC

    if not, it will create an instance of the class. • Struts will set the state of the UserActionForm using corresponding fields from the HttpServletRequest. No more dreadful request.getParameter() ...

    BobBuilder_app

    I also tried an assorted number of sorting routines like double pivot quick sort, timsort, insertion sort and found that they all were slower than the internal .net quicksort routine in my tests. ...

    谷歌地图 delphi 封装库 2013 0.1.9 全面支持google maps api

    - Bug fixed: TGMMap -> bug fixed on RemoveLinkedComponent when trying delete an object without being the list created. - Bug fixed: JavaScript => when it had figures of different types together, ...

    django-master-class

    Unit testing is a crucial aspect of software development that ensures the reliability of individual components or functions within an application. In the context of Django, unit testing helps ...

Global site tag (gtag.js) - Google Analytics