KMS TechCon 2014 - Interesting in JavaScript

497 views

Published on

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

  • Be the first to comment

  • Be the first to like this

KMS TechCon 2014 - Interesting in JavaScript

  1. 1. © 2014 KMS Technology
  2. 2. INTERESTING IN JAVASCRIPT DUY LAM KMS TECHNOLOGY MAY 2014
  3. 3. JAVASCRIPT THINGS  function(){ }  Closure  function(){this.name;}  Module Pattern
  4. 4. 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
  5. 5. CLOSURE function can access variables declared in outer scope check out the demo @ http://bit.ly/techcon2014-closure
  6. 6. CLOSURE (CONT.) something wrong here
  7. 7. CLOSURE (CONT.) showNameFunc became a closure  closure is a Function object  closure has environment when the function is created
  8. 8. 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
  9. 9. MODULE PATTERN – THE PROBLEM Global variable’s problems  Implicit global variable  Bad integration with other programs
  10. 10. MODULE PATTERN – SOLUTION here is an example
  11. 11. MODULE PATTERN – ADVANCE USES
  12. 12. 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
  13. 13. THANK YOU © 2014 KMS Technology

×