最近买了本javascript高级程序设计,想要提高自己的JS能力,可是书看了一半语法也基本知道,但感觉书中的语法怎么和prototype里面的不一样呢?如:
书中定义类的方式:
function ClassA(sColor) {
_classes.defineClass("ClassA", prototypeFunction); this.init(sColor); function prototypeFunction() {
ClassA.prototype.init = function (sColor) {
this.parentMethod("init");
this.color = sColor;
}; ClassA.prototype.sayColor = function () {
alert(this.color);
}; }而我看到的一些js 如prototype 里面的代码却是另外的一些格式
var Prototype = {
Version: '1.4.0',
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', emptyFunction: function() {},
K: function(x) {return x}
}var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
我不明白,这种格式即然不符合js的格多,为什么能够被浏览器解释呢?
请各位达人们指点迷惑,勿见笑…………!
书中定义类的方式:
function ClassA(sColor) {
_classes.defineClass("ClassA", prototypeFunction); this.init(sColor); function prototypeFunction() {
ClassA.prototype.init = function (sColor) {
this.parentMethod("init");
this.color = sColor;
}; ClassA.prototype.sayColor = function () {
alert(this.color);
}; }而我看到的一些js 如prototype 里面的代码却是另外的一些格式
var Prototype = {
Version: '1.4.0',
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', emptyFunction: function() {},
K: function(x) {return x}
}var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}
我不明白,这种格式即然不符合js的格多,为什么能够被浏览器解释呢?
请各位达人们指点迷惑,勿见笑…………!
不太明白你的意思!我知道prototype里面用的是json格式,可是这种格式跟javascript之间的关系到底是什么?为什么它也能被解释!如果它也是javascript的一种语法格式,那JS书里怎么对它提都没提起过呢?我想用这样的格式放到c#里面肯定是编译通不过吧!javascript真的是让人郁闷啊,定义一个类有N种方式!
javascript的东西用到的时候再查吧
谁他妈 JB 整成这样!
也不测试一下就直接更新上来!!
新版慢死了,还总是加载不上来,唉!真 T M D 想骂人!
谁他妈 JB 整成这样!
也不测试一下就直接更新上来!!
新版慢死了,还总是加载不上来,唉!真 T M D 想骂人!
谁他妈 JB 整成这样!
也不测试一下就直接更新上来!!
新版慢死了,还总是加载不上来,唉!真 T M D 想骂人!
谁他妈 JB 整成这样!
也不测试一下就直接更新上来!!
新版慢死了,还总是加载不上来,唉!真 T M D 想骂人!
谁他妈 JB 整成这样!
也不测试一下就直接更新上来!!
我一开始的时候也觉得javascript用的时候查下手册就行,直到我接触到AJAX,直到看到公司的高手用javascript做出一个基于B/S结构的即时报价系统,我不这样认为了!js里面要学的东西有很多,很多语法与C#不相同的!js的功能也是远超乎你的想想力的,当客户机运算能力相当可观的今天,基于富客户端的程序越来越流行,js是有很大发展潜力的!
Skyey