1 / 74

http:// proglit.com /

http:// proglit.com /. the javascript language. SA. BY. Javascript is not Java. Brendan Eich at Netscape in 1995 named in deal between Netscape and Sun ECMA standard calls it ECMAScript. only language in all modern web browsers currently focus of lots of optimization work.

vita
Download Presentation

http:// proglit.com /

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. http://proglit.com/

  2. the javascript language

  3. SA BY

  4. Javascript is not Java

  5. Brendan Eich at Netscape in 1995 named in deal between Netscape and Sun ECMA standard calls it ECMAScript

  6. only language in all modern web browsers currently focus of lots of optimization work

  7. the DOM AJAX (Document Object Model, the hierarchy of objects representing page content in web browsers) (Asynchronous Javascript and XML, a technique to submit/request data without refreshing the page)

  8. dynamic and (a little) functional object-oriented programming via prototyping

  9. numbers booleans strings arrays (lists) objects (dictionaries) functions null

  10. http://proglit.com/

  11. + addition - subtraction/negation / division * multiplication % modulus

  12. x * 3 + 9 ((x * 3) + 9) (+ (* x 3) 9)

  13. foo(a, b, c) bar() (foo a b c) (bar)

  14. foo() (foo()) (foo) foo (foo) ((foo)) foo

  15. lvalue rvalue foo = bar / 2 (foo = (bar / 2)) (= foo (/ bar 2))

  16. x = y = z = 4 + 2 (x = (y = (z = (4 + 2)))) (((x = y) = z) = (4 + 2)) the = operator is right-to-left associative

  17. http://proglit.com/

  18. x = 3; cow = 2 + x; foo(1); rat = bar();

  19. free-form syntax x = 3; x=3 ; x = 3 ;

  20. foo(); // ignore this /* ignore all this too */ bar();

  21. /* apple /* banana orange */ lemon */

  22. _foo foo_bar $foo foo$bar

  23. var varname; varname = expression; var monkey; var zebra = 3;

  24. undefined varjeff; foo(jeff); // OK foo(amanda); // error

  25. function function(parameters) {body}

  26. var helen = function(apple, orange) { return apple + orange; }; var dan = helen(3, 5);

  27. ! not === equals !== not equals && and || or < less than > greater than <= less than or equal >= greater than or equal

  28. !true// false !false// true !null// true !0 // true !“”// true !undefined // true

  29. 3 === 3// true 3 === -2// false !true === false// true

  30. (3 === 3) || (2 > 4) // true

  31. http://proglit.com/

  32. if / else if(condition) {body} else if(condition){body} else {body} while while(condition) {body}

  33. if (x === 3) { foo(); } else { bar(); }

  34. var i = 0; while (i < 5) { foo(); i = i + 1; }

  35. var foo = function() { return bar; }; foo(); // error var bar = 3; foo(); // OK

  36. var foo = function() { bar = 6; return bar; var bar; }; foo(); // 6

  37. nested functions var foo = function(a) { var bar = function(b) { returnb + 3; }; returnbar(a); }; foo(5); // 8

  38. Function A B C Function A D B C Function E C B D A

  39. var foo = function(a) { var bar = function(a) { returna + 3; }; returnbar(a); }; foo(5); // 8

  40. var foo = function() { vara = 3; var bar = function(b) { returna + b; }; a = 5; returnbar(6); }; foo(); // 11

  41. http://proglit.com/

  42. closure var foo = function(a) { var b = 4; return function(c) { returna + b + c; }; }; varbar = foo(2); var ack = foo(3); bar(6); // 12 ack(6); // 13

  43. closure var foo = function(a) { return function() { a = a + 2; returna; }; }; varbar = foo(2); var ack = foo(3); bar(); // 4 bar(); // 6 ack(); // 5

  44. objects {properties} object[string]

  45. var foo = {}; var bar = {“bill”: 1 + 1, “diana”: 11}; var ack = bar[“bill”]; // 2 bar[“bill”] = 3; foo[“ned”] = 8; ack = foo[“ted”]; // undefined

  46. var foo = {}; var bar = {bill: 1 + 1, diana: 11}; var ack = bar.bill; // 2 bar.bill = 3; foo.ned = 8; ack = foo.ted; // undefined

  47. methods var foo = {}; foo.bar = function() { this.ack = 3; }; foo.bar();

  48. var foo = {}; foo.bar = function(x) { x.ack = 3; }; foo.bar(foo);

  49. var foo = {}; foo.bar = function() { this = 3; //error }; foo.bar();

More Related