-
new this
The Animal.init is interesting. "this" refer to Animal function, which can be newed. It shows that function is alsow object, some object can be newed. some can not be newed
function Animal() { }; Animal.prototype = { name: "Animal", sayName: function() { alert(this.name); } }
-
A better javascript constructor, factory
What is wrong with the following code?
-
Closure in javascript
I have read a book "Pro JavaScript Techniques", inside it define closure as follow.
-
Dyamically adding function to how hierarchy
We can add functionality to whole hierarchy by changing the prototype, for example.
-
In javascript, everything is what?
When I learned c# long ago, I was told everything in .net is object. I used javascript long before I learned c#. But I have never asked myself this question. Now I ask myself this question. I think everything in javascript is object too.
- Static object which can not create object
- Dynamic object which can create object, its name in javascript is function.