From Colettapedia
Jump to navigation Jump to search


  • functions are objects in javascript
  • anonymous functions - no name
var foo = function(callback){
 return function() {
  print" return function called.";
  • can add properties to functions, i.e., = 'baz';
  • javascript does not have classes but
var Foo = function {};
Foo.prototype {
 'bar': function() {};
  • can extend prototypes at any time
  • can also extend with a built in type
Number.prototype.celciusToFahrenheit = function(){};


  • all functions in Drupal.behaviors are executed onready (when DOM is ready)
  • functions get a context parameter to act on


  • ex: slide show, wrap images in markup
var elem - Drupal.theme()

developing javascript widgets

  • think about compatibility
    • your js wid should not interfere, don't behave as if they're alone on the page.

DOM Traversal

Traversing an HTML Table with JavaScript and DOM Interfaces