kms techcon 2014 - interesting in javascript
DESCRIPTION
My topic in KMS TechCon 2014, an internal technology event at KMS Technology Vietnam companyTRANSCRIPT
© 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
REFERENCE
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this
• http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Closures• Demo:
– http://bit.ly/techcon2014-function– http://bit.ly/techcon2014-this– http://bit.ly/techcon2014-closure