ݺߣ

ݺߣShare a Scribd company logo
javascriptױ
޿(ֵͨ)
20135
ѵĿ꼰
ѵĿ꣺
? js̻
? ջŻʶûŻ
? αдģ黯άjs
? jsһЩĸ
ѵ
? ٰjavascriptʹð
γʱ
? 120
γ̴
? ΪʲôҪѧϰjavascript
C ̽javascriptӦ÷Χǰ
C ̽ճп
? javascript
C ʹjsʵ
C ʵԭԼصjsĸ
? дάjavascript
C ΪʲôҪģ黯ģ黯
C һЩԼԼͼ
? õŻûŻ
C 秼ɵͬʱͨԭ굽jsһЩĸ
? Сϰ
ΪʲôҪѧϰjavascript
? javascriptӦ
C ǰ
C 
C jsӦ.png
? г
C ʲôʱthis
C ǰ̨ҼȽϸӵʱ򣬸оɢ
C ˿ʱıʱᱻ˸
C ĿJsļļҲͳһʽ
C дһЩͨõĺآ֪ô֯áԺظʹ
ΪʲôҪѧϰjavascript
? ογآǣ
C ijܵ÷
C ij¼±׼ʹ
? ǣ
C ҿjavascriptɴ굽
C ΪдԼĿ⡢ԼĿܴ»
ογ̵·ͼ

д
ά


Ż
û
Ż
ĸ
(ԭ͡)
javascript
? һ̵Ļص
C 
? һԡΪ캯
? Լԡ(ν̬ԡ̬)
C 
? ʵһϵԡ
C װ
? ˽ԡⲿ޷
C ̳
? ԴӸм̳ԡ
C ̬
? ʹΪ͵ıĶ
? Եдķ
۵гõĻԣآȫ
javascript
? ȿʵֵIJ
C 
? һԡΪ캯
? Լԡ(ν̬ԡ̬)
C 
? ʵһϵԡ
C װ
? ˽ԡⲿ޷
C ̳
? ԴӸм̳ԡ
C ̬
? ʹΪ͵ıĶ
? Եдķ
jsͲԣֶ֧̬آ

ʵ֡࡯ľ̬ԡ̬
javascript
? ࡢ̬ԡ̬
C 캯=
C 캯=̬
C 캯ķ=̬
? demo
캯function,ֻآ
javascript
? ҪIJ֡
C 
? һԡΪ캯
? Լԡ(ν̬ԡ̬)
C 
? ʵһϵԡ
C װ
? ˽ԡⲿ޷
C ̳
? ԴӸм̳ԡ
C ̬
? ʹΪ͵ıĶ
? Եдķ
ʵֶʵԺͷ
javascript
? Ĺ캯
C ʹthis󹫿Ըֵ
C ʹconstructor.prototypeԱķ
? ʹnewʵ
C demo
? ʲô?
C ʹnewù캯thisָǡҪصĶ
á
C Ǹ˼
C ˼
? Ϊʲôآһ壿
? prototypeôģ
ʲôԭͣ??
javascript
? javascriptĺĸ(1) ԭͺԭ
? new캯.prototypeΪġԭ
͡
? ʶʱjs˳ԭһֱϲ
javascript
? ԭͺԭ
Object.prototype ʲô?
? ĶҲǴObject

? ǰ˵newִй̣
a.__proto__ === Object.prototype
ע__proto__V8ԡʽԭ͡ʵ֣آDZ׼
javascript
? С
C ͨnewʵڲ
? ½նobj䡰ԭ͡=캯.prototype
? ù캯,Dʹڹ캯thisʼָҪصobj

? ͨthisԣͶpublic
? ͨ캯.prototypeӷͶж
public
C Tips:
? ڹ캯آreturnjsĬϷع¶
? return,newصreturnȥĶ
javascript
? ڡthis
C 캯еthis(ʹnewù캯)
? ָǡҪĶá
C µthis,磺
? setTimeout:
? Jquery¼稶:
javascript
? thisļֳ
C ȫ
? this === global (¾window)
C 
? ȡںĵ÷ʽ
C setTimeout/setIntervalthis === global
C obj.function():this === obj
C ֱӵ: this === null(л۽תΪwindow)
C demo
ʹevalִд룬ôеthiseval
ĵthis
javascript
? е鷳ġ̳
C 
? һԡΪ캯
? Լԡ(ν̬ԡ̬)
C 
? ʵһϵԡ
C װ
? ˽ԡⲿ޷
C ̳
? ԴӸм̳ԡ
C ̬
? ʹΪ͵ıĶ
? Եдķ
ʵִӻм̳Ժͷ
javascript
? ȿʵ(demo)
javascript
? ϵͼ
terry
name terry
_proto_ <ref>
Man
prototype <ref>
new F()
_proto_ <ref>
constructor <ref>
talk <func>
Human
prototype <ref>
Human.prototype
talk <func>
walk <func>
lucy
name lucy
_proto_ <ref>
new F()
_proto_ <ref>
constructor <ref>
talk <func>
Woman
prototype <ref>
ԭͶ

ִķ

ԭͶ
ִķ

ԭͶ
ԭͶ
ִл෽
ͨмʹöԭ͵޸آӰ쵽ԭ
javascript
? ˽װ
C 
? һԡΪ캯
? Լԡ(ν̬ԡ̬)
C 
? ʵһϵԡ
C װ
? ˽ԡⲿ޷
C ̳
? ԴӸм̳ԡ
C ̬
? ʹΪ͵ıĶ
? Եдķ
ⲿ޷
javascript
? javascriptĺĸ(2) ִġ
C ִ(execution context)
? ÿjs붼һcontext
? ࣬һִ
C ȫ
C 
C evalĵ
? һִģԼģӶγһ
ջ(Context Stack)
? ִ󣬸ijջ

浱ǰ
Ķ
ı
浱
ǰVO͸

Thisָ
javascript
? ꡰִġǶ(Ĉջ)
javascript
? javascriptĺĸ(3) 
C 
? ߱
? ڵǰĶġ
C 2
? ȫ:ȫֶ
? ֲ:ڲ
? jsûп鼶(if,while,for)
C IJ
? Ķ(ǰVO)ʼ
? ûҵϲϼcontextŵvo
ͨЩ֪һֻڵǰcontextǶ
׵Ӻڱʡʵַװ
javascript
? javascriptĺĸ(3) 


ȫ
javascript
? ù캯װ˽б
آͬĶӦӵآͬ˽ԣΪʲôдᵼ
2آͬĶͬһ˽ԣ
javascript
? סհ
C ʲôDZհ
? ʹôݵļ
C ECMAScriptбհʵ
? ʹúΪһ(Ϊݣɽܺʽ
Ժֵ)
? ں[scope]ڲб游Ϣ
(VO/AO)
? һһհҲγɡ
ֻѺص
ⲿհص

ʵǶDZհ
javascript
? հע
C ͬһжĶհͬһ
parentContext.[scope]
C Demo
javascript
? ˽ԡװ
javascript
? һ
C 캯:ڹһĺ
C ̬ԡֱڹ캯ӵԡ
C ʹnewù캯ʵ
C ԣֱthis
C ڹ캯.prototypeӵķ
C ˽/ڹ캯ʹvarľֲʵ
װ
C ̳Уͨ캯һԭͶ󣬸öԭ;
ǻ๹캯prototype
ֻ̣дôĵһ
Ҫһ˼
дάĴ
? ʲôǿάĴ룿
C ڶĺڱдĽűӰ

C ֪ʲôõ
C űļйһܿҵЩϵ

C ࡢߺ֯
C ҪĴʱܹܿѴ֯˵

C
дάĴ
? αдάĴ
C ѭһЩҹϵ׼Լ(ҲƶԼĹ
Ҫַͳһ)
C ģnamespaceѴ֯ģ
C javascriptһЩΪõϰ
ЩΪ
C ѧϰһЩȽϺõıϰߣDһҪ֪Ϊʲôô
js͵IJԣȱ㹻ԤƣԱд
άĴҪ
дάĴ
? 
C /캯upper camel case(ĸдÿ
ĸд)
C public/lower camel case(ĸСдÿ
ĸд)
C private/»߿ͷ+lower camel case
C »߷ָȫдַ
дάĴ
? ġӡͳõļ
C ۽ֺŲƴ
C ֱʹδı
C ΪʲôҪthis
C ʹnewô죿
C ģ黯
дάĴ
? ۽ֺŲ(Auto Semicolon Insert)
дάĴ
? ʹ
C ںĶҪõı(ѭڵi,j
)
? ͳһ
? Ӵɶ
C آҪֱʹδ ı
? Ӱȫĵı
дάĴ
? this
C ںִеʱthisѰı
C Ҫ
дάĴ
? Լ캯ʹ÷ʽ
C 캯Ӧʹnew
C һ˲Ա,ôʾ
дάĴ
? ģ֯
C C#еnamespace,javaеġ
C ʹöģnamespace
C ʹִеĺģ
? װģ˽
? IJΪģṩⲿķȨ
C ģآͬļЭͬ
C Demo
дάĴ
? ģ黯ĸ߼
C ģY
C ģ첽ء
? ģ·ɣģļַӳϵ
? ˳
? سɹʧܵĻص
? Դ
C 
? http://requirejs.org/
? http://seajs.org/docs
ŻûŻ
? Ż
C 
C forѭŻ
C 溯穹
C ŻDOM
C Jqueryѡ穹
? Demo
ŻûŻ
? ûŻ
C ͨص㣺
? ޷ʱȡԵġ۷
? ּûǰܿݵչٶȡõġˬ
? ûϾʱ׼
C һЩüɣ
? ͼƬԤ
C Demo
? ҳ첽
? ٲ
ûŻûһآĹѭġ
Έʹ
Сϰ
? publicԺpublicֱӦʹ
ʽʵ֣Ϊʲô
C A)this B)캯.prototype
? ԁS2javascriptŻķʽҪ㡣
? ԁS1ԼĿʹùûŻɣ
˵Ŀĺԭ

More Related Content

ٽױ