kms techcon 2014 - interesting in javascript

13
© 2014 KMS Technology

Upload: duy-lam

Post on 10-May-2015

224 views

Category:

Software


1 download

DESCRIPTION

My topic in KMS TechCon 2014, an internal technology event at KMS Technology Vietnam company

TRANSCRIPT

Page 1: KMS TechCon 2014 - Interesting in JavaScript

© 2014 KMS Technology

Page 2: KMS TechCon 2014 - Interesting in JavaScript

INTERESTING IN JAVASCRIPT

DUY LAMKMS TECHNOLOGY

MAY 2014

Page 3: KMS TechCon 2014 - Interesting in JavaScript

JAVASCRIPT THINGS

function(){ } Closure function(){this.name;} Module Pattern

Page 4: KMS TechCon 2014 - Interesting in JavaScript

FUNCTION

function is a Function object Local variable arguments object (it is not

an Array) function calls itself

Conflicting on variable names

check out the demo @ http://bit.ly/techcon2014-function

Page 5: KMS TechCon 2014 - Interesting in JavaScript

CLOSURE

function can access variables declared in outer scope

check out the demo @ http://bit.ly/techcon2014-closure

Page 6: KMS TechCon 2014 - Interesting in JavaScript

CLOSURE (CONT.)

something wrong here

Page 7: KMS TechCon 2014 - Interesting in JavaScript

CLOSURE (CONT.)

showNameFunc became a closure closure is a Function object closure has environment when the function is created

Page 8: KMS TechCon 2014 - Interesting in JavaScript

THIS KEYWORD

Context of this : in global and in a function Bind a particular object to this inside a

function

check out the demo @ http://bit.ly/techcon2014-this

Page 9: KMS TechCon 2014 - Interesting in JavaScript

MODULE PATTERN – THE PROBLEM

Global variable’s problems Implicit global variable Bad integrationwith other programs

Page 10: KMS TechCon 2014 - Interesting in JavaScript

MODULE PATTERN – SOLUTION

here isan example

Page 11: KMS TechCon 2014 - Interesting in JavaScript

MODULE PATTERN – ADVANCE USES

global import

module exportaugment module

Page 13: KMS TechCon 2014 - Interesting in JavaScript

THANK YOU

© 2014 KMS Technology