Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
JAVASCRIPT REFERENCES & VALUES
Slide 2
Slide 2 text
Name @brn (⻘野健利) Occupation フロントエンドエンジニア・ネイティブエンジニア Company Cyberagent アドテクスタジオ AI Messenger OSS Contributor of V8 About http://info.b6n.ch
Slide 3
Slide 3 text
References and Values ࢀর
Slide 4
Slide 4 text
References and Values ࢀর ࢀর
Slide 5
Slide 5 text
References and Values ࢀরؒతʹΦϒδΣΫτΛมߋ͢Δ ͦͷΦϒδΣΫτΛมߋ͢Δ
Slide 6
Slide 6 text
References or Values? KBWBTDSJQUࢀরͱͷ྆ํΛ͏ ΦϒδΣΫτຖʹͲ͏ѻΘΕΔ͔ܾ·͍ͬͯΔ
Slide 7
Slide 7 text
Javascript object traits ࢀর "MMWBMVFTFYUFOET0CKFDU TUSJOH OVNCFS CPPMFBO
Slide 8
Slide 8 text
Pass by reference/value const A = const B = ࢀর A = B =
Slide 9
Slide 9 text
Pass by reference const A = {}; const B = A; B.x = 1; console.log(A); // { x: 1 }
Slide 10
Slide 10 text
Pass by value const A = 1; const B = A; B++; console.log(A); // 1
Slide 11
Slide 11 text
Until here… ͱɺ͜͜·Ͱ͕Α͘ݴΘΕ͍ͯΔ ࠓճ͏ͪΐ͍ਂ۷Γͯ͠Έ͍ͨ
Slide 12
Slide 12 text
Mutable, Immutable KBWBTDSJQUʹ มߋՄೳͳͱมߋෆՄೳͳ͕͋Δ TUSJOH OVNCFS CPPMFBOมߋͰ͖ͳ͍
Slide 13
Slide 13 text
Special cases OVNCFSͱCPPMFBO͠Ͱ͋Δ͜ͱ͕ଟ͍ ͨͩ͠TUSJOH৭ʑͳ͕͋Δέʔε͕ଟ͍ 7ͰTUSJOHࢀরͱͳ͍ͬͯΔ
Slide 14
Slide 14 text
String behave like value let A = 'a'; let B = A; A += 'b' // Create new instance and assign to self. console.log(A); // 'ab'; console.log(B); // 'a;
Slide 15
Slide 15 text
Immutablity make reference to value *NNVUBCMFͳจࣈྻ͕ͷΑ͏ʹৼΔ͏͕ ࣮ࡍʹͯ͢ࢀরΛ͍ͯ͠Δ
Slide 16
Slide 16 text
What is reference? ࢀরͱͳΜͩΖ͏
Slide 17
Slide 17 text
Pointer ΦϒδΣΫτੜ͞ΕΔͱώʔϓྖҬͱ͍͏ϝ ϞϦʹׂΓͯΒΕΔ ͦͷΦϒδΣΫτΛૢ࡞͢Δ߹ͦͷϝϞϦྖ ҬΛࢦࣔ͢͠ΞυϨεΛඞཁͱ͢Δ ͜Ε͕ϙΠϯλͱݺΕΔͷ
Slide 18
Slide 18 text
Pointer is value KTΤϯδϯΛ࣮͍ͯ͠Δ$$ͷੈքͰ ϙΠϯλͦͷͷ·ͨͰ͋Δ ͦͷͨΊϙΠϯλͷϙΠϯλΛ࡞ͬͨΓͰ͖Δ
Slide 19
Slide 19 text
Reference is value ͔͠͠KBWBTDSJQUͷੈքͰࢀরͷࢀর࡞Εͳ͍ ͭ·Γࢀরৗʹ͠ͱͳΔ
Slide 20
Slide 20 text
pass by copy reference ͭ·ΓKBWBTDSJQUͰ ࢀর ϙΠϯλ Λ͍ͯ͠͠Δ ࢀরͷ͠ͱͳ͍ͬͯΔ
Slide 21
Slide 21 text
Appendix 7෦ͷจࣈྻ࣮Λ؆୯ʹ
Slide 22
Slide 22 text
String in V8 7Ͱจࣈྻ͕ҎԼͷΫϥεʹ͔Ε͍ͯΔ 4FR0OF#ZUF4USJOH 4FR5XP#ZUF4USJOH $POT4USJOH 5IJO4USJOH 4MJDFE4USJOH
Slide 23
Slide 23 text
String in V8 ಛʹTVCTUSJOHΛߦͬͨΓͯ͠ ৽ͨʹจࣈྻΠϯελϯεΛ࡞͢Δ߹ 3PQFͱ͍͏ΞϧΰϦζϜΛར༻ͨ͠ $POT4USJOH͕ར༻͞ΕΔ
Slide 24
Slide 24 text
Rope จࣈྻͷ݁߹͕ߴ0 MPHO ׂߴ0 MPHO औΓग़͠0 MPHO
Slide 25
Slide 25 text
Rope 5PEBZJTXFBSFKBWBTDSJQUFS`T 5PEBZJT XFBSFKBWBTDSJQUFS`T 3005
Slide 26
Slide 26 text
Rope 5PEBZJT 3005 8FBSF KBWBTDSJQUFS`T 53&&
Slide 27
Slide 27 text
Summary ࢀরͱ͔Β3PQF·ͰோΊͯΈ·ͨ͠ ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠