-
What is javascript
Here is how Douglas Crockford defined javascript
Javascript is a functional language with dynamic objects and familiar syntax.
In his definition, he stressed the most important feature of javascript is functional language(scheme), secondary important feature is dynamic objects(self), the last part is familiar syntax(java). The familiar syntax tend to new javascript developer think that javascript is easy language, but it is not. To really unleash the power of javascript, it is necessary to have deep understanding of functional feature and dynamic objects.
-
adding a new memeber to all objects in javascript
function Person(){} -
How to tell type of an object in javascript
We can use typeof, instanceof, and constructor to tell type of an object. But they have different effect. The "typeof" operator will return "object" for all custom types . "instanceof" will return true, if the object's constructor is in the list of constructor hierarchy. "constructor" will return the top constructor in the constructor hierarchy. Below is some test code
function Person() {} function Developer(){} Developer.prototype = new Person(); -
a merge function
function merge(root){ for ( var i = 0; i < arguments.length; i++ ) for ( var key in arguments[i] ) root[key] = arguments[i][key]; return root; } -
position property
In css the position properties, such as top, left, right, bottom is auto by default, one miss conception is that they are 0. Which is not the case. So when you change from positon values (static, relative; absolute, fixed) without setting the top/left/right/bottom, there should be no change, except that absolute and fixed value will disable the margin merge.