Skip to main content

Diigo Home

6 Advanced JavaScript Techniques You Should Know - The Diigo Meta page

sixrevisions.com/...ipt-techniques-you-should-know - Cached

This link has been bookmarked by 24 people . It was first bookmarked on 08 Oct 2009, by Cameron Morgan.

  • 13 Nov 09
    wingman07
    brent lawrence

    "6 Advanced JavaScript Techniques You Should Know"

    javascript techniques js tutorials webdev advanced bestpractices programming

  • 09 Nov 09
  • 03 Nov 09
  • 26 Oct 09
  • 11 Oct 09
    sanilunlu
    Seçkin Anıl Ünlü

    Here are some advanced JavaScript techniques and tips all web developers should know.

    javascript techniques tutorials programming webdev

    • 1. Closures to Extend Variable Scope
    • Simply put, closures allow variable scope to be extended past the common scope restrictions of functions.
    • 20 more annotations...
  • 10 Oct 09
    fabgonber
    Fabian Gonzalez Berger

    interesantes tecnicas para utilizar JS

    js javascript datosti webdesign diseñoweb

  • 09 Oct 09
  • maanmehta
    Maan Mehta

    "There have been a number of articles published over the years that discuss best practices techniques for JavaScript. I thought I would go a little bit beyond the scope of those articles and outline a number of advanced techniques and practices that I have personally used or read about that could be invaluable in certain circumstances.

    This article doesn’t necessarily cover every detail of the methods I’m describing, but provides an overview, along with code examples, of some practical JavaScript coding techniques."

    javascript techniques js advanced dev

  • atreyu_bbb
    Javier Neira

    //2. Object Literals to Pass Optional Arguments
    function showStatistics(args) {
    document.write("<p><strong>Name:</strong> " + args.name + "<br />");
    document.write("<strong>Team:</strong> " + args.team + "<br />");
    if (typeof args.position === "string") {
    document.write("<strong>Position:</strong> " + args.position + "<br />");
    }
    if (typeof args.average === "number") {
    document.write("<strong>Average:</strong> " + args.average + "<br />");
    }
    if (typeof args.homeruns === "number") {
    document.write("<strong>Home Runs:</strong> " + args.homeruns + "<br />");
    }
    if (typeof args.rbi === "number") {
    document.write("<strong>Runs Batted In:</strong> " + args.rbi + "</p>");
    }
    }

    showStatistics({
    name: "Mark Teixeira"
    });

    showStatistics({
    name: "Mark Teixeira",
    team: "New York Yankees"
    });

    showStatistics({
    name: "Mark Teixeira",
    team: "New York Yankees",
    position: "1st Base",
    average: .284,
    homeruns: 32,
    rbi: 101
    });
    //Using Namespaces to Prevent Conflicts
    if (typeof MY == "undefined") {
    MY = new Object();
    MY.CUSTOM = new Object();
    }

    MY.CUSTOM.namespace = function() {
    function showStatistics(args) {
    ..................
    }
    showStatistics({
    name: "Mark Teixeira",
    team: "New York Yankees",
    position: "1st Base",
    average: .284,
    homeruns: 32,
    rbi: 101
    });
    }
    MY.CUSTOM.namespace();

    javascript tips bestpractices code snippets

    • function showStatistics(args) {
      document.write("<p><strong>Name:</strong> " + args.name + "<br />");
      document.write("<strong>Team:</strong> " + args.team + "<br />");
      if (typeof args.position === "string") {
      document.write("<strong>Position:</strong> " + args.position + "<br />");
      }
      if (typeof args.average === "number") {
      document.write("<strong>Average:</strong> " + args.average + "<br />");
      }
      if (typeof args.homeruns === "number") {
      document.write("<strong>Home Runs:</strong> " + args.homeruns + "<br />");
      }
      if (typeof args.rbi === "number") {
      document.write("<strong>Runs Batted In:</strong> " + args.rbi + "</p>");
      }
      }

      showStatistics({
      name: "Mark Teixeira"
      });

      showStatistics({
      name: "Mark Teixeira",
      team: "New York Yankees"
      });

      showStatistics({
      name: "Mark Teixeira",
      team: "New York Yankees",
      position: "1st Base",
      average: .284,
      homeruns: 32,
      rbi: 101
      });
    • Object-oriented JavaScript implements namespace-like principles due to the fact that properties and methods are declared inside of objects, thus there are less likely to be conflicts. A conflict could arise, however, through object names. And very likely, the conflict will occur "silently", thus you may not be alerted to the issue immediately.
    • 2 more annotations...
  • 08 Oct 09
  • agmaftei
    adrian maftei

    Here are some advanced JavaScript techniques and tips all web developers should know.

    javascript techniques must to know