KMS TechCon 2014 - Interesting in JavaScript

Post on 10-May-2015

223 views 1 download

Tags:

description

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

Transcript of KMS TechCon 2014 - Interesting in JavaScript

© 2014 KMS Technology

INTERESTING IN JAVASCRIPT

DUY LAMKMS TECHNOLOGY

MAY 2014

JAVASCRIPT THINGS

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

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

CLOSURE

function can access variables declared in outer scope

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

CLOSURE (CONT.)

something wrong here

CLOSURE (CONT.)

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

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

MODULE PATTERN – THE PROBLEM

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

MODULE PATTERN – SOLUTION

here isan example

MODULE PATTERN – ADVANCE USES

global import

module exportaugment module

THANK YOU

© 2014 KMS Technology