- 浏览: 389459 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
Javascript is a dynamic type function. you cannot do something like reflection in other strong langauge.
though you cannot do something like typeof(obj), while you can test if a function is the contructor that cretaed the object.
basically you can test if a function is the constructor to an object by two ways
- obj isinstanceof Functin
- obj.contructor == Function
below is the html file that shows you have to do that.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript" src="../unit.js"></script> <script type="text/javascript"> function Ninja() { } var ninja = new Ninja(); window.onload = function () { test("object type test", function () { assert(typeof ninja == "object", "However the type of the instance is still an object."); assert(ninja instanceof Ninja, "The object was instantiated properly."); assert(ninja.constructor == Ninja, "The ninja object was created by the Ninja function"); var ninja2 = new ninja.constructor(); assert(ninja2 instanceof Ninja, "Still a ninja object."); }); }; </script> <style type="text/css" > #results li.pass { color: Green } #results li.fail { color: Red } </style> </head> <body> <ul id="results" /> </body> </html>
发表评论
-
javascript - trick to cross browser DOM ready event
2012-08-24 08:23 900the "ready" event ... -
javascript - trick to simulate mouseenter and mouseleave
2012-08-23 08:31 2228Previously we discussed javasc ... -
javascript - trick to simulate the change event
2012-08-22 08:51 1610In the previous discussion a ... -
javascript - trick to simulate bubbling submit event
2012-08-22 08:03 882In the previous discussion abou ... -
javascript - trick to implement bubbling submit event
2012-08-23 07:55 670Following up to the javascrip ... -
javascript - trick to detect bubbling supportability
2012-08-20 22:22 932Event delegation is oe of the b ... -
javascript - trigger event and custom events
2012-08-20 21:58 2044In the previous post - javascri ... -
javascript - trick to handlers management
2012-08-20 08:19 995We have discussed "javascr ... -
javascript - trick to centralized store
2012-08-20 07:52 785For a number of reasons it's ... -
javascript - trick to fix the event object
2012-08-20 07:47 849Many browsers, especially In ... -
javascript - tricks to deal with colors
2012-08-15 08:34 742There are a couple of ways to r ... -
javascript - trick to manipulate the opacity
2012-08-15 08:26 744All other browsre may have supp ... -
javascript - trick to test visibility of an element
2012-08-15 08:15 497though there is a visible prope ... -
javascript - trick to get and set height and width
2012-08-15 08:05 519when looking at properties t ... -
javascript - trick to set/get attributes that expects px values
2012-08-16 11:00 494When setting a number into a ... -
javascript - trick to get and set CSS style
2012-08-16 11:00 718while it will not be so much tr ... -
javascript - trick to normalize href for IE
2012-08-16 10:59 507IE is again the only browser th ... -
javascript - trick IE form and its expando attribute
2012-08-16 10:59 1008there is a known issue that if ... -
javascript expando and attributes
2012-08-14 08:15 1010expando is something like this ... -
javascript - trick to getText and setText
2012-08-14 07:40 1105it is not as simple as you thin ...
相关推荐
With it's project-based approach, this book is carefully constructed to guide you from how JavaScript fits into the overall Drupal architecture through to making you a master of the jQuery library in...
of the BZ reaction to simulate the evolution of these spirals. The models typically use cellular automata to allow progression of a wavefront through a notional substrate. Usually a single substrate ...
The MIMO channel models constructed via the principle of maximum entropy in [1]1, are compared to measurement data collected in a field campaign carried out in Oslo, Norway, at 2.1 GHz and 5.2 GHz....
We introduce the noise level function (NLF), which is a continuous function describing the noise level as a function of image brightness. We then estimate an upper bound of the real NLF by fitting a ...
Use QuickSort algorithm to sort the array S that has n elements and constructed by the random() function. To compare the result with ones solved by other sorting algorithms, such as Straight selection...
this heritage of the craft is going to arm you with some of the right tools to make a diference in your daily work. The craft of graphic design has changed little in the past fifty years. We’re ...
The automatic emotion detection systems constructed and described in the book make it possible to index and subsequently search through music databases according to emotion. In turn, the emotion maps...
that is, the other objects they work with, only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned ...
concept of software and has been hailed as part of the solution to the so-called “software crisis”. It has given the possibility that software components can be constructed and reused with ...
Through the authors' carefully constructed explanations and examples, you will develop an understanding of Swift grammar and the elements of effective Swift style. This book is written for Swift 3.0 ...
data are suggested, according to which corresponding time series of interest for econometric analysis can be constructed. As an example of the relevance of the procedure, the autoregressive ...
Developing neural network ... On the task of object detection, the learned features by NASNet used with the Faster-RCNN framework surpass state-of-the-art by 4.0% achieving 43.1% mAP on the COCO dataset
Chapter 7Tokens, Values, and Variablesdescribes the tokens of the language from which statements are constructed, the types defined by the language and their allowed values, and the variables that ...
control method attempts to create 2 objects of the same name. This once again returns AE_ALREADY_EXISTS. When this exception occurs, it invokes the mechanism that will dynamically serialize the ...
It is also important to have a strong understanding of modal analysis, from which the total response of a system can be constructed. Finally, it helps to know how to take the results of large dynamic ...
A graphsearch method to illustrate exhaustive results to the desired information based on the constructed knowledge graph is proposed. A case of a 500 kV station example is then demonstrated to show ...
The purpose of this book is to teach the C programming language, using examples running on the JumpStart MicroBox hardware. A college-level course syllabus can be constructed around this book and its ...
The simulation for the system constructed with the help of MATLAB/SIMULINK. The SPWM method improves the efficiency and reduces the total harmonics distortion in the output voltage.
now possible to implement the various types of the Bayesian inference thanks to advances in computing technology and the use of new sampling methods, including Markov chain Monte Carlo (MCMC). Such ...