Information : Knowledge Base
Real Estate Web Design - Information
  homes for sale

Real Estate Web Design - Information





Javascript-Functions


Web Content Solutions - Real Estate Web Design


 Real Estate Reports Search Engine  
Select your search criteria
All Words Exact Phrase Any Words



Functions

A function is a block with a (possibly empty) argument list that is normally given a name. A function may give back a return value.

function function-name(arg1, arg2, arg3) {
  statements;
  return expression;
}

Example: Euclid's original algorithm of finding the greatest common divisor. (This is a geometrical solution which subtracts the shorter segment from the longer):

function gcd(segmentA, segmentB) {
  while (segmentA != segmentB) {
    if (segmentA > segmentB)
      segmentA -= segmentB;
    else
      segmentB -= segmentA;
  }
  return segmentA;
}

The number of arguments given when calling a function may not necessarily correspond to the number of arguments in the function definition; a named argument in the definition that does not have a matching argument in the call will have the value undefined . Within the function the arguments may also be accessed through the arguments list (which is an object); this provides access to all arguments using indices (e.g. arguments[0], arguments[1], ... arguments[n] ), including those beyond the number of named arguments.

Basic data types (strings, integers, ...) are passed by value wheras objects are passed by reference.

Functions as objects and anonymous functions

Functions are first-class objects in JavaScript. Every function is an instance of Function , a type of base object. Functions can be created and assigned like any other objects, and passed as arguments to other functions. Thus JavaScript supports higher-order functions. For example:

Array.prototype.fold = function (value, functor) {
  var result = value;
  for (var i = 0; i < this.length; i++) {
    result = functor(result, this[i]);
  }
  return result;
}
var sum = [1,2,3,4,5,6,7,8,9,10].fold(0, function (a, b) { return a + b })

results in the value:

55


Since Function can be instantiated, JavaScript allows the creation of anonymous functions, which can also be created using function , e.g.:

new Function( "return 1;" )

function() { return 1; }


The implicit object available within the function is the receiver object. In the example below, the value of the alert property is an anonymous function:

function Point( x, y ) {
  this.x = x;
  this.y = y;
}
   
Point.prototype.alert = function() {
  window.alert( "(" + this.x + "," + this.y + ")" );
}
   
var pt = new Point( 1, 0 );
pt.alert();

Methods can also be added within the constructor:

function Point( x, y ) {
  this.x = x;
  this.y = y;
  this.alert = function() {
    window.alert( "(" + this.x + "," + this.y + ")" );
  }
}
   
var pt = new Point( 1, 0 );
pt.alert();


There is no need to use a constructor if only a single instance of an object is required and no private members are needed - properties and values can be added directly using an initialiser:

var pt = {
   x: 1,
   y: 0,
   alert: function() {
     window.alert( "(" + this.x + "," + this.y + ")" );
   }
}
pt.alert();

Members declared as variables in the constructor are private; members assigned to this are public. Methods added or declared in the constructor have access to all private members; public methods added outside the constructor don't.

function myClass() {
  var msg = "Hello world!";

  /*
     This is shorthand for:
     var myPrivateMember = function()
  */
  function myPrivateMember() {
    alert(msg);
  }

  this.myPublicMember = function() {
    myPrivateMember();
  }
}

myObj = new myClass;

myObj.anotherPublicMember = function() {
  /*
     These won't work as anotherPublicMember
     is not declared in the constructor:

  myPrivateMember();
  alert(msg);

     These won't work either:

  this.myPrivateMember();
  alert(this.msg);

  */
  this.myPublicMember();
}

Note: The functions '__defineSetter__' and '__defineGetter__' are implementation-specific and not part of the ECMAScript standard.

For detailed control of member access, getters and setters can be used (e.g. to create a read only property or a property that the value is generated):

function Point( x, y ) {
  this.x = x;
  this.y = y;
}
   
Point.prototype.__defineGetter__(
  "dimensions",
  function() { return [this.x, this.y]; }
);
   
Point.prototype.__defineSetter__(
  "dimensions",
  function( dimensions ) { this.x = dimensions[0]; this.y = dimensions[1]; }
);
   
var pt = new Point( 1, 0 );
window.alert( pt.dimensions.length );
pt.dimensions = [2,3];





Information Request

I would like to see a real site (and pricing) as well as information on availability for my area for lead generation.


Website Design is available to all areas. The two lead generation systems are not. Many areas are currently available but going fast. The reason areas go fast is that Google and craigslist will not let you oversaturate an area with the same lead system from the same company.
My Name
Email
Phone
Design #(s)

 


GENERATE LEADS

LEARN MORE >>
Customer Support


Full Name :
Domain :
This area is for existing clients only. A message will be sent instantly to support personal Mon-Sun.

Please use this area only for critical issues! For standard changes or support, please use the HELP CENTER of your website. The general rule of thumb is that if you can log into your site, use the HELP CENTER of your website.

Top SEO Techniques
  • Link Building - Quality Inbound Links
  • Proper Text / Keyword Density (Title, Heading and Meta Tags)
  • Image Tag Attribution
  • Relavant Text Links
  • Robust, regularly updated XML Sitemap
  • Relavant, Consistant Content
  • Easy Blogging (Our system will ask you questions)
  • Social Media Hooks and Youtube Video Hooks






REALTOR® -- A registered collective membership mark that identifies a real estate professional who is a member of the National Association of REALTORS® and subscribes to its strict Code of Ethics.   Realty Web Designers and Real Estate Web Site Design are not affiliated with REALTOR®, it's logos or trademarks.   Thanks for your interest in real estate web design.