2007-08-08
prototype 1.4的学习记录
关键字: prototype Ajaxjs 代码
- // start include prototype.js
- //Prototype 的第一个变量
- var Prototype = {
- //Version 表示当前版本是Prototype 1.4
- Version: '1.4.0',
- //ScriptFragment 是一个很有用的正则表达式,可以匹配一段Javascript片段
- ScriptFragment: '(?:)((\n|\r|.)*?)(?:<\/script>)',
- //这是两个很无聊的函数 emptyFunction是一个空函数
- //K 返回传入的参数
- emptyFunction: function() {},
- K: function(x) {return x}
- }
js 代码
- //Class.create,用来构造一个类
- //调用Class.create会,可以返回一个函数,这个函数会把传入的参数赋给当前的对象,arguments是Javascript里面的一个关键字,表示函数的所有参数。这样Prototype就可以模拟Java构造函数的机制了。
- var Class = {
- create: function() {
- return function() {
- this.initialize.apply(this, arguments);
- }
- }
- }
- //Abstract是一个空的对象,Abstract的意思好像是要说这是一个抽象
- var Abstract = new Object();
- //把源对象所有的属性值都赋给
- Object.extend = function(destination, source) {
- for (property in source) {
- destination[property] = source[property];
- }
- return destination;
- }
js 代码
- Object.extend = function(destination, source) {
- if(!destination){
- destination={};
- }
- for (property in source) {
- destination[property] = source[property];
- }
- return destination;
- }
js 代码
- //这个方法觉得没多大的作用,只是相当于一个ToString方法而已
- Object.inspect = function(object) {
- try {
- if (object == undefined) return 'undefined';
- if (object == null) return 'null';
- return object.inspect ? object.inspect() : object.toString();
- } catch (e) {
- if (e instanceof RangeError) return '...';
- throw e;
- }
- }
发表评论
- 浏览: 20938 次
- 性别:

- 来自: 广州

- 详细资料
搜索本博客
我的相册
我的印章
共 59 张
共 59 张
最近加入圈子
最新评论
-
分享去华为面试的经历
3.(10+c)*4+3=70+c 得出c为9 第2步中D=3+B*4=7是怎么 ...
-- by 小龟爬爬 -
看C#随笔
C#吸取了JAVA的优点,弥补了JAVA的不足,很不错
-- by netlynx206 -
分享去华为面试的经历
三分钟....等我算出来前三分钟开始算
-- by hyxkangta123 -
分享去华为面试的经历
A=2 写错
-- by zhouzhao21 -
分享去华为面试的经历
大约五分钟, E = 8 , A = 4 穷举法,笔算。
-- by zhouzhao21






评论排行榜