|
Declare a variable
|
// declarators
// (keywords include user-defined types
// and built-in types)
|
// Only use var declare a class variable
|
// Only use var declare a class variable
|
var varName : Type;
|
// var
// No var means Globle variable,
//but it should be initialized while it is used.
|
Don’t declare
|
|
Declare a named constant
|
const readonly
|
define
|
define
|
const a:Number = 1;
|
n/a
|
begins with an uppercase letter (A-Z)
|
|
Create a new instance of a class
|
new
|
new
|
new
|
new
|
new
//JavaScript does not support true classes.
//it is possible to define pseudoclasses in JavaScript.
|
Class method new
|
|
Create a new object
|
new
|
new
|
new
|
{ memeberName : member }
|
new
|
|
|
Assign an object to an object variable
|
=
|
=
|
=
|
=
|
=
|
=
|
|
Function/method does not return a value
|
void
|
function
|
function
|
function
|
function
|
def
|
|
Overload a function or method (Visual Basic: overload a procedure or method)
|
n/a
|
n/a
|
n/a
|
n/a
|
n/a
|
n/a
|
|
Refer to the current object
|
this
|
$this
|
$this
|
this
|
this
|
self
|
|
Make a nonvirtual call to a virtual method of the current object
|
// n/a
|
// n/a
|
// n/a
|
// n/a
|
// n/a
|
|
|
Retrieve character from a string
|
str[10] // where str is a string
|
$userName = "kimi";
Echo $userName[i]
|
$userName = "kimi";
Echo $userName[i]
|
str.charAt(3);
|
var str = "I am a string."
document.write(str.charAt(0)); // get the first character.
|
str[10]
|
|
Declare a compound data type (structure)
|
struct class interface
|
class
|
classinterface
|
n/a
|
|
class Struct
|
|
Initialize an object (constructor)
|
// Constructors
// or system default type constructors
// Class Constructors
|
// Constructors
// or system default type constructors
// (concept, not keyword)
|
function __construct()
|
public class ClassA{ public ClassA(){} }
|
// Constructors
|
initialize
|
|
Terminate an object directly
|
n/a
|
n/a
|
n/a
|
n/a
|
|
|
|
Method called by the system just before garbage collection reclaims an object7
|
Destructors
|
n/a
|
function __destruct()
|
n/a
|
n/a
|
|
|
Guarantee that unmanaged resources are disposed of after use
|
using
|
n/a
|
n/a
|
n/a
|
n/a
|
|
|
Initialize a variable where it is declared
|
// initialize to a value:
int x = 123;
// or use default constructor:
int x = new int();
|
$myString = 'test string';
$myInt = 12;
|
$myString = 'test string';
$myInt = 12;
|
var a : int = 1;
|
// initialize to a value
var x = 123;
//or use default constructor:
var str = new String("I am string.");
|
my_array = [ 1, 2, 3 ]
song = Song.new("Bicylops", "Fleck", 260)
|
|
Take the address of a function
|
delegate
|
n/a
|
n/a
|
function abc(){}
var ptr : Function = abc;
|
n/a
|
method instance_method
|
|
Callback
|
delegate
|
call_user_func
function printName(){
echo "Mike";
}
$v = "printName";
echo $v();
|
call_user_func
function printName(){
echo "Mike";
}
$v = "printName";
echo $v();
|
n/a
|
|
Method.call
|
|
Declare that an object can be modified asynchronously
|
volatile
|
n/a
|
n/a
|
n/a
|
n/a
|
|
|
Force explicit declaration of variables
|
// All variables must be declared prior to use n/a
|
n/a
|
n/a
|
n/a
|
n/a
|
|
|
Enable local type inference
|
n/a
|
n/a
|
n/a
|
n/a
|
|
|
|
Test for an object variable that does not refer to an object
|
obj == null
|
$obj == nullis_null
|
$obj == nullis_null
|
obj == null
|
obj == null
|
Obj == nil
nil? method
|
|
Value of an object variable that does not refer to an object
|
null
|
null
|
null
|
null
|
undefined or null
|
nil
|
|
Test for a database null expression
|
n/a
|
n/a
|
n/a
|
n/a
|
n/a
|
|
|
Test whether a Variant variable has been initialized
|
n/a
|
empty() or isset()
|
empty() or isset()
|
varName==undefined
|
var a;
a == undefined;
|
|
|
Define a default property
|
Indexers
|
n/a
|
__toString
|
n/a
|
n/a
|
to_s
|
|
Object cloning
|
n/a
|
n/a
|
clone__clone
|
n/a
|
n/a
|
|