虚拟机,编译原理,应用框架

随笔分类 -  javascript 技巧

动态语言中的技巧
准备写一个世界第一快的js的css3 selector engine
摘要:我在看sizzle和peppy的源代码,发现他们的速度还有提升的空间, 我准备使用jit技术实现一个世界最快的javascript css3 selector engine. css3选择器也有一些不方便 比如说伪类选择器,只运行"且"选择,不运行"或"选择,要"或"的话,把前面的抄下来吧,效率低多了. 经过jit编译过后的selector成为一个函数,接受一个参数ct,表示容器.选择器将从这... 阅读全文

posted @ 2008-10-31 00:18 文宇祥 阅读(1042) 评论(1) 推荐(0)

javascript OOP:实现继承、多态与封装
摘要:代码是随手写的,只提供思路。 这个原理很简单,看代码就懂,不多说了。 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->(function (){ var h = 0; handle = function (){return h++};... 阅读全文

posted @ 2008-08-30 23:55 文宇祥 阅读(605) 评论(1) 推荐(0)

private constructor的模拟
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->(function (Package){ var _key = {}; var ClassA = function (key_){ if (_key !== ke... 阅读全文

posted @ 2008-08-07 09:56 文宇祥 阅读(248) 评论(0) 推荐(0)

利用apply来进行参数传递和转换
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->function t(){ var fns = Array.prototype.concat.apply([], arguments); for (var i = 0; i < ... 阅读全文

posted @ 2008-08-04 10:46 文宇祥 阅读(465) 评论(0) 推荐(0)

代理constructor,prototype且不让instanceof失效
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->function NewClasse(superclass){ return function classe(){ if (classe.prototype != sup... 阅读全文

posted @ 2008-08-01 01:34 文宇祥 阅读(292) 评论(0) 推荐(0)

javascript实现StrExp
摘要:主要实现了类似jsp里的el表达式的功能,甚至于比el表达式更加强大。 思路很简单,就是利用eval绑定可见域。利用这个思路可以作出很多强大的东西。 当前其中也用到了String.prototype.replace的强大功能。 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.Cod... 阅读全文

posted @ 2008-07-31 15:44 文宇祥 阅读(688) 评论(0) 推荐(0)

javascript: LoadModule, LoadModules
摘要:注意这里使用Function来避免eval的可见域问题。 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> function loadModule(/*Module*/mod/*location*/, /*Function*/cb/*ca... 阅读全文

posted @ 2008-07-28 22:43 文宇祥 阅读(1097) 评论(0) 推荐(0)

javascript实现yield
摘要:没想到代码一次测试成功.~~只不过是FF下面,修改一下支持IE了。由于IE不认function表达式. Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->var Iterator = function (fn) { var corou... 阅读全文

posted @ 2008-07-27 16:12 文宇祥 阅读(2910) 评论(7) 推荐(0)

判断函数调用是否来自new操作符.
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->function A () { A.prototype._ = A; if (this._ === A) { alert('new call') } el... 阅读全文

posted @ 2008-07-24 10:42 文宇祥 阅读(218) 评论(0) 推荐(0)

导航