• Feedburner RSS
  • Comments RSS
  • Post RSS

Multiple ways to declare variables

April 17th, 2009

When declaring variables like objects or arrays, there is more than 1 way to declare them. I’m not exactly sure which way is faster, but I have used both scenarios in a variety of occasions. I’m putting this here just to help clarify they mean the same thing.

//Object Declaration 1
var objData:Object = new Object();
objData.fname = "Mr.";
objData.lname = "Krinkle";
 
//Object Declaration 2
var objData:Object = {fname:"Mr.", lname:"Krinkle"};
 
//Arrays Declaration 1
var arrData:Array = new Array();
arrData.push("Mr.");
arrData.push("Krinkle");
 
//Arrays Declaration 2
var arrData:Array = ["Mr.","Krinkle"];

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">