There can be no Triumph without Loss,No Victory without Suffering,No Freedom without Sacrifice.
All you have to decide is what to do with the time that is given to you.
Get busy Living, or Get busy Dying?
  首页 | 留言给我 | 订阅 Rss | CLI | 黄白之恋 Posts:158   Hits: 5271700    Comments: 173    
<<  <  2024 - 07  >  >>
 About Me
 Name: ZhangSichu
 Sex: Male
 Age: 32
  ·C++/C(5)  RSS
  ·软件工程(1)  RSS
  ·杂事/随感(26)  RSS
  ·.Net/Java(30)  RSS
  ·面向对象程序设计(5)  RSS
  ·汇编/破解(0)  RSS
  ·平面设计(3)  RSS
  ·SQL(5)  RSS
  ·COM/COM+(2)  RSS
  ·Web开发(81)  RSS
 My Friends
Back Forward Refresh Home 2024年7月23日 星期二 RSS CLI Mine Sweeper. In Javascript.

  Some useful Javascript tips.
字体大小 [ ]

1.The typeof prefix operator returns a string identifying the type of a value。

Click to Open in New Window

(1). function setOffests(){
    var left = calculateOffsetLeft(<element>);
    var top = calculateOffsetTop(<element>);
    // element the need descripted part.

(2).function calculateOffsetLeft(field)
    return calculateOffset(field,”offsetLeft”);

(3).function calculateOffsetTop(field)
    return calculateOffset(field,”offestTop”)

(4).function calculateOffset(field, attr)
    Var offset=0;
      offset += field[attr];
      field = field.offsetParent;
} operator 意义
var newObject = new aObject();
new aObject() returns a new object with a link to aObject.prototype.

Click to Open in New Window

每一个JavaScript对象都有一个内置的属性,名为ProtoType,ProtoType属性保存着对另一个JavaScript对象的引用,这个对象作为当前对象的父对象。当通过点记法引用对象的一个函数或属性时,若对象上没有这个属性或方法,此时就会使用对象的ProtoType属性。当出现这种情况时,将检查对象ProtoType属性所引用的对象,检查看是否有所请求的属性或函数,如果ProtoType的属性引用的对象也没有所需要的函数或方法,则进一步检查这个对象(prototype属性引用的对象)的prototype属性。依次沿着链向上找,直到找到所要请求的属性或方法,或者到链尾,如果已经到了链尾还没有找到,则返回undefined。从这种意义上讲,这种继承是一种 has a 关系 不是 is a 关系。

4.JavaScript 基于类的继承
Function createInheritance(parent, child){
  var property
  for(property in parent){
    if(!child[property]) {
      child[property] = parent[property];

5.Minification vs Obfuscation
Reduce the amount of source code to reduce download time.
Minification deletes whitespace and comments.
Obfuscation also changes the names of things.
Obfuscation can introduce bugs.
Never use tools that cause bugs if you can avoid it.
  Posted @ 11/24/2006 10:04:57 AM | Hits (73103) | Comment (0

  Post Comment
标题 *
作者 *
密码 记住我
评论 *

Stable in Firefox 1.5 2.0Stable in IE6 IE7Stable in MozillaStable in Netscape V0.1.7507
Powered By ZhangSichu
Copyright © ZhangSichu
Download source code. Download source code