• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Javascript Tip and Triks
 

Javascript Tip and Triks

on

  • 695 views

 

Statistics

Views

Total Views
695
Views on SlideShare
686
Embed Views
9

Actions

Likes
2
Downloads
0
Comments
0

1 Embed 9

http://www.scoop.it 9

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Javascript Tip and Triks Javascript Tip and Triks Presentation Transcript

    • JavascriptTips and Tricks
      @EBvi
    • Declaring a Function
      function foo() {}
      var bar = function() {}
      The difference is that foo is defined at parse-time for a script block, whereas bar is defined at run-time.
    • Anonymous function
      (function (){})
    • Different ways of calling functions
      alert (“Hello, World!");
      (alert) (“Hello, World!");
      (function(x,y,z) {return (x+y+z)}) (1, 2, 3);
    • Using functional concepts
      Functions need not have names all the time.
      Functions can be assigned to variables like other values.
      A function expression can be written and enclosed in parentheses for application later.
      Functions can be passed as arguments to other functions.
    • JS does not have block scope.
      varx = 1;
      {
        var x = 2;
      }
      alert(x); // outputs 2
      Block statements do not introduce a scope.
    • {}
      {} is object notation in JavaScript.
      An extremely terse and flexible way to pass information.
    • ;
      At the end of the last script without a ; on the end. If you have a ; at the start on yours, it's safe.
    • ++ and --
      The ++ (increment) and -- (decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling to viruses and other security menaces. There is a plusplus option that prohibits the use of these operators.
      - Douglas Crockford
    • use === and !== instead of == and !=
      == is not transitive. If you use === it would give false for all of these statements as expected.
    • Reference
      http://stackoverflow.com/questions
      http://en.wikipedia.org/wiki/Unobtrusive_JavaScript
      http://javascript.crockford.com
      http://www.ibm.com/developerworks/library/wa-javascript.html
      https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Statements
      JavaScript: The Good Parts