易截截图软件、单文件、免安装、纯绿色、仅160KB

JavaScript 构造函数 myhere

/**
* JavaScript 是面向对象的语言,但是他的面向对象不是基于类的,是基于原型的;
* 但是他的一些特性(函数是数据),使得它可以模拟基于类的面向对象,但是 JavaScript 并不支持和 Java 一样的类,
* 因此 JavaScript 中的"类"可以称作"伪类"
*/
//
/**
* 构造函数: js 中用来和 new 运算符一起使用的函数称作构造函数
*
* 构造函数通常没有返回值,构造函数初始化作为 this 的值传递来的对象,并且没有返回值;
*
* 然而,一个构造函数是允许返回一个对象的值的,并且,如果他这么做,返回的对象成为 new 表达式的值;
* 在此情况下,作为 this 的值的对象将会被抛弃。
* [ jQuery 中的 jQuery.fn.init 构造函数有返回值 ]
*/
//
function User( name, age){
this.name = name;
this.age = age;
// return; // 返回 this
// return null; // 返回 this
// return this;
// return []; // 返回 []
// return function(){}; // 返回 这个 function,抛弃 this
// return false; // 返回 this
// return new Boolean( false); // 返回新 boolean;抛弃 this
// return 'hello world'; // 返回 this
// return new String( 'hello world'); // 返回 新建的 string,抛弃 this
// return 2; // 返回 this
// return new Number( 32); // 返回新的 number,抛弃 this
}
var me = new User( 'myhere', 23);
/**
* new 运算符的工作过程
* 1, 创建一个空对象
* 2, 设置这个对象的原型;一个对象的原型就是他的构造函数的 prototype 属性的值。
* 所有的函数都有一个 prototype 属性,当这个函数被定义的时候,prototype 属性自动的创建和初始化。
* prototype 属性的初始化值是一个对象,这个对象只有一个属性,就是 constructor,他指回到和原型相关联的那个构造函数
* 3, 将这个空对象作为 this 的值传递给构造函数来执行这个构造函数,及用构造函数初始化对象
* 4, 构造函数是否有 return 语句
有 return 语句: (具体情况见上面例子)
是否 return 一个对象(注意必须是对象)
是:则使用这个对象作为 new 表达式的值
否:忽略 return 语句返回构造函数初始化的对象
无 return 语句:
返回 this
*/
//
//
/**
* 所有函数都有一个 prototype 属性
* 每个对象都有一个 construct


相关文档:

JavaScript调用本地EXE文件与查看注册表代码

<!--JavaScript 调用客户端应用程序-->
<script type="text/javascript">  
    function exec(command) 
    {  
          window.oldOnError   =   window.onerror;  ......

Client Side JavaScript Validation

Struts Validator Framework provides an easy-to-use mechanism for performing client-side validation. It's very useful to validate some fields on the client-side before sending the data to the server for processing. By this way we can ensure that the data send to the server is valid. Performing valida ......

JavaScript实现 panel的显示隐藏

<script language="javascript">
    function closeOpen(Panel) {
        var test = document.getElementById('Panel');
        if (test.style.display == "none") {
       &nb ......

javascript中event.keycode

javascript中event.keycode
 keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
keycode 32 = space space ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号