javascript: the good parts for humans (part 1)

29
JavaScript The good parts for humans (part 1) B Anjaneyulu Reddy Email: [email protected] Twitter: @_anji www.evibe.in

Upload: b-anjaneyulu-reddy

Post on 18-Dec-2014

183 views

Category:

Technology


0 download

DESCRIPTION

Introduction

TRANSCRIPT

  • 1. JavaScript The good parts for humans (part 1) B Anjaneyulu Reddy Email: [email protected] Twitter: @_anji www.evibe.in
  • 2. Training Schedule Day 1 o History o Grammar o Objects Day 2 o Functions o Inheritance Day 3 o Arrays o RegEx o Misc Day 4 o Bad parts o JSON o JSLint o Other best practices Day 5
  • 3. Who is the author of JS? Brendan Eich
  • 4. In which year was JS shipped? 1995
  • 5. Name the company in which JS was born? NetScape
  • 6. History of JavaScript (1 of 3) Java applets failed o Microsoft's self implementation of Java VM o long loading time o native OS GUI look and feel How Flex is different from Java applets? Java applet vs Flash vs Silverlight
  • 7. History of JavaScript (2 of 3) `Scheme` like scripting language Brand new programming language in 10 days Java Scheme Self LiveScriptJavaScript JScript
  • 8. History of JavaScript (3 of 3) W3C ECMA - ECMA Script Why haven't the bad parts been fixed?
  • 9. Introduction to JS What is JS? World's most popular programming language World's most confused programming language A language of many contrasts o Write without learning o Loosely typed o Prototype inheritance o Dynamic objects o Language with design mistake: Global variables
  • 10. Bad parts Global variables Semicolon insertion + adds and concatenates `typeof ` `with` and `eval` phony array == and != false, null, undefined, NaN
  • 11. JS falsy values false null undefined NaN '' - empty string 0 - the number 0 All other values are truthy.
  • 12. Grammar White Space
  • 13. Grammar Names Reserved words: abstract, boolean, break, byte, case, catch, char, class, const, continue, debugger, default, delete, do, double, else, enum, export, extends, false, final, finally, float, for, function, goto, if, implements, import, in, instanceof, int, interface, long, native, new, null, package, private, protected, public, return, short, static, super, switch, synchronized, this, throw, throws, transient, true, try, typeof, var, volatile, void, while, with, Infinity, NaN, undefined
  • 14. Grammar Numbers
  • 15. Grammar Exercise 1 1 === 1.0 ? isNaN(); 10 / 0 ? 0 / 0 ? Number.MAX_VALUE;
  • 16. Grammar String String are immutable length, toUpperCase() 'c' + 'a' + 't' === 'cat' ?
  • 17. Grammar Statements JS scoping? JS blocks labels - to break loops 1.html
  • 18. Grammar Statements
  • 19. Grammar Statements disruptive statement break statement return statement
  • 20. Grammar Conditional Statements if switch block if statement
  • 21. Grammar Conditional Statements switch statement case clause
  • 22. Grammar Looping Statements while for do
  • 23. Grammar Looping Statements for statement
  • 24. Grammar Expression
  • 25. Objects What is an Object? Except JS simple types, everything else is an object { numbers, strings, booleans, null and undefined} Objects are mutable keyed collection
  • 26. Objects literal
  • 27. Objects object literal
  • 28. Objects Exercise 2 o Sample Object o TypeError - undefined o || Operator o && Operator o pass by reference o prototypal inheritance Object.beget dynamic relationship o hasOwnProperty o for in statement o global abatement
  • 29. Thank You