View RSS Feed

Post a JavaScript

Custom, non DD related JavaScripts from other members.

  1. DOM manipulation code

    Here's some of my personal DOM manipulation code:

    Code:
    Object.extend = function(o1, o2) {
      for (var x in o2)
        if (o2.hasOwnProperty(x))
          o1[x] = o2[x];
    
      return o1;
    };
    
    Object.extend(Object, {
      copy: function(o) {
        return Object.extend({}, o);
      },
    
      fromArray: function(o) {
        var r = {};
    
        Array.map(function(pair) { r[pair[0]] = pair[1]; }, a);
    ...

    Updated 04-06-2009 at 12:47 AM by Twey

    Tags: 1'", zvwqendc Add / Edit Tags
    Categories
    Post a JavaScript , JavaScript & Ajax
  2. Generics in Javascript

    I just used this code to vent some frustration earlier, hope you all like it. It's pretty self-explanatory. It's probably too theoretical to go into the DD script archives, so I'll just leave it lying about here.

    Code:
    var Generic = (function() {
      var MATCH_FAIL = {},
          MATCH_ANY  = function() { return MATCH_ANY; };
    
      function create(fallback) {
        var s = function() {
          for (var i = 0, args = Array.prototype.slice.call(arguments),
    ...