Prototype Theory
- 格式:ppt
- 大小:236.50 KB
- 文档页数:42


对原型prototype的详解
刚开始接触对象原型时⼤脑就开始起义了,脑⼦就转不灵清了。就感觉怎么着这个概念就是灌输不进去,俗称断路。后⾯找了很多资
料,最主要的还是要借助于《JavaScript语⾔精髓》这本书,让我对这此豁然开朗,希望说的不对的地⽅请给予指正,谢谢。
⼀、什么是原型?
原型包含⼀个对象("prototype"对象),是构造函数特有的属性。将所有实例对象共享的属性和⽅法放在⾥⾯,不需要共享的属性和⽅
法则放在构造函数⾥⾯。它能继承私有和共享属性和⽅法。
⼆、prototype实例
⾸先创建⼀个构造函数,具有name属性。
function Person(name){
= name;
}
构造函数创建好之后,我想创建两个实例,并且输出他们的name值。
var p1 = new Person("张三");
var p2 = new Person("李四");
console.log(+","+); /* 输出张三,李四*/
那现在我想给p1张三在添加⼀个eat属性,我要他可以吃饭(food),那既然你张三都可以吃饭,那我李四要要吃饭,那我也输出
p2.eat,但是结果是undefined……如下所⽰。
p1.eat = "food";
console.log(p1.eat); /* 输出food */
console.log(p2.eat); /* 输出undefined */
原来是张三⾃⼰偷偷摸摸的去吃饭,没让李四知道,哎╮(╯▽╰)╭。那既然这样,Person就不得不添加⼀个共⽤属性eat了,得让⼤家⼀
起吃饭呀。
Person.prototype.eat = "food";
console.log(p1.eat); /* 输出food */
console.log(p2.eat); /* 输出food,我也可以吃饭了…… */
添加Person.prototype.eat = "food"这个以后,eat属性就被添加到原型库中,eat属性就可以共享了(李四说“太好了,我也可以吃饭了
js中的prototype.txtprototype 是在 IE 4 及其以后版本引入的一个针对于某一类的对象的方法,而且特殊的地方便在于:它是一个给类的对象添加方法的方法!这一点可能听起来会有点乱,别急,下面我便通过实例对这一特殊的方法作已下讲解: 首先,我们要先了解一下类的概念,JavaScript 本身是一种面向对象的语言,它所涉及的元素根据其属性的不同都依附于某一个特定的类。我们所常见的类包括:数组变量(Array)、逻辑变量(Boolean)、日期变量(Date)、结构变量(Function)、数值变量(Number)、对象变量(Object)、字符串变量(String) 等,而相关的类的方法,也是程序员经常用到的(在这里要区分一下类的注意和属性发方法),例如数组的push方法、日期的get系列方法、字符串的split方法等等, 但是在实际的编程过程中不知道有没有感觉到现有方法的不足?prototype 方法应运而生!下面,将通过实例由浅入深讲解 prototype 的具体使用方法:
1、最简单的例子,了解 prototype:(1) Number.add(num):作用,数字相加实现方法:Number.prototype.add = function(num){return(this+num);}试验:alert((3).add(15)) -> 显示 18
(2) Boolean.rev(): 作用,布尔变量取反实现方法:Boolean.prototype.rev = function(){return(!this);}试验:alert((true).rev()) -> 显示 false是不是很简单?这一节仅仅是告诉读者又这么一种方法,这种方法是这样运用的。
2、已有方法的实现和增强,初识 prototype:(1) Array.push(new_element) 作用:在数组末尾加入一个新的元素 实现方法: Array.prototype.push = function(new_element){ this[this.length]=new_element; return this.length; } 让我们进一步来增强他,让他可以一次增加多个元素! 实现方法: Array.prototype.pushPro = function() { var currentLength = this.length; for (var i = 0; i < arguments.length; i++) { this[currentLength + i] = arguments[i]; } return this.length; } 应该不难看懂吧?以此类推,你可以考虑一下如何通过增强 Array.pop 来实现删除任意位置,任意多个元素(具体代码就不再细说了)(2) String.length 作用:这实际上是 String 类的一个属性,但是由于 JavaScript 将全角、半角均视为是一个字符,在一些实际运用中可能会造成一定的问题,现在我们通过 prototype 来弥补这部不足。 实现方法: Length = function(){ var arr=this.match(/[^\x00-\xff]/ig); return this.length+(arr==null?0:arr.length); } 试验:alert("EaseWe空间Spaces".cnLength()) -> 显示 16 这里用到了一些正则表达式的方法和全角字符的编码原理,由于属于另两个比较大的类别,本文不加说明,请参考相关材料。
Skopos Theory
(2012-11-30 22:29:56)
1.(translation studies) The idea that translating and interpreting should
primarily take into account the function of both the source and target
text.
2.
o 1995, Paul Kussmaul, Training The Translator, John
Benjamins Publishing Co, p. 149:
2.The functional approach has a great affinity with Skopos theory.
The function of a translation is dependent on the knowledge,
expectations, values and norms of the target readers, who are again
influenced by the situation they are in and by the culture. These
factors determine whether the function of the source text or
passages in the source text can be preserved or have to be modified
or even changed.
Introduction to the Skopos Theory
The Skopos theory is an approach to translation which was put
forward by Hans Vemeer and developed in Germany in the late 1970s
一一一一一一一中外文学文化研究本栏目责任编辑:王力
OverseasEnglish海外英语2017年2月
Analysisof“NirvanainFire”BasedonSemanticPrototypeTheory
ZHANGXue-ying
(HunanNormalUniversity,Changsha410000,China)
Abstract:Euphemismsareusedfrequentlyinhumandailylife,andwiththedevelopmentofcognitivescienceinrecentyears,
peopletrytousevariouscognitivelinguistictheoriestostudyeuphemisms.Inthepaper,thedefinitionandorigin,construction
principlesandclassificationsofeuphemismsarepresented.,andthenthemainideasandfeaturesofsemanticprototypetheory
areintroduced.Thelastpartistheconcreteanalysisofeuphemismsbasedon“NirvanainFire”withthehelpofsemanticproto-
typetheory.
Keywords:euphemisms;semanticprototypetheory;NirvanainFire
中图分类号:I106文献标识码:A文章编号:1009-5039(2017)03-0181-03
1Introduction
Asacommonlinguisticphenomenon,euphemismhasbeena
hottopicforalongtime,andit’simportanttoknowmoreinforma⁃