lunedì, maggio 02, 2005

Un potente Javascript per .NET

This is probably the biggest leap in functionality for JScript since the 1996 introduction of JScript version 1.0 with Internet Explorer 3.0. JScript has traditionally been used to develop client-side scripts due to its ubiquitous, cross-platform support on the Internet, but we've been seeing a steady increase in the usage of JScript on the server?particularly in Active Server Pages (ASP). For example, your favorite Web site (MSDN) uses a large amount of server-side JScript, as do many other sites on the Internet. Un ottimo tutorial sul nuovo Javascript, capace di cose interessanti, come in questo esempio
// Wrap the function inside a class statement.
class Car
{
  // Declare the class members. I've used types in this example,
  // but they are not required. I could have also marked the class
  // as being 'expando' and not had to declare these members.
  var make : String;
  var color : String;
  var year : int;

  // Old constructor function, unchanged.
  function Car(make, color, year)
  {
     this.make = make;
     this.color = color;
     this.year = year;
  }

  // Move the function inside the class
  function GetDescription()
  {
     return this.year + " " + this.color + " " + this.make;
  }
}

// Create and use a new Car object
var myCar = new Car("Accord", "Maroon", 1984);
print(myCar.GetDescription());
Aggiungiamo che il compilatore JScript (jsc.exe) è in tutte le macchine su cui è installato il Framework .NET e il discorso si fa molto interessante.

Nessun commento: