C#
|
Python
|
JScript
|
int x = 3;
string y = "foo";
FooBarQux fbq = make_fbq ();
|
x = 3
y = "foo"
fbq = make_fbq()
|
var x = 3;
var y = "foo";
var fbq = make_fbq ();
|
expr_1 = expr_2 = expr_3;
|
|
expr_1 = expr_2 = expr_3;
|
Class c = new Class (params)
|
|
var c = new Class (params)
|
Class[] c = new Class [size]
|
|
|
Type[] l = new Type[] { expr_1, expr_1, ..., expr_n }
|
l = (expr_1, expr_1, ..., expr_n)
|
var l = new Array { expr_1, expr_1, ..., expr_n }
|
if (cond) return foo;
do_something ();
return bar;
|
if cond:
return foo
//You can also say:
return foo if cond
do_something()
return bar
|
if (cond) return foo;
do_something ();
return bar;
|
|
if cond:
answer = 42
//or
answer = 42 if cond
|
|
|
|
|
try ...
catch (FooException e) { ... }
catch (BarException e) { ... }
|
try:
...
except e as FooException:
...
except e as BarException:
...
|
try ...
catch (e) { ... }
|
try { foo (); bar (); }
catch (Exception e) { baz (); }
finally { qux (); }
|
try:
foo()
bar()
except e:
baz()
ensure:
qux()
|
try { foo (); bar (); }
catch (e) { baz (); }
finally { qux (); }
|
throw new System.ArgumentException ("foo");
|
raise System.ArgumentException("foo")
|
|
|
//exception if cast fails:
t = cast(type, expr)
//or
//null if cast fails:
t = expr as type
|
(type is loose in JScript, implicit casting)
|
using System.Windows.Forms;
Button button = control as Button;
if (button != null) ...
else ...
|
import System.Windows.Forms
button = control as Button
if button != null:
...
else:
...
|
JScript doesn't really have the concept of modules, but you can import other JScript libraries by reading them into global
memory:
var g_fso = new ActiveXObject( "Scripting.FileSystemObject" );
var g_ts = g_fso.OpenTextFile( "MyJSFunctions.js" );
var g_lib = g_ts.ReadAll();
g_ts.Close();
eval( g_lib );
|
using System;
using SWF = System.Windows.Forms;
using System.Xml;
...
Console.WriteLine ("foo");
SWF.Form x = new SWF.Form ();
XmlDocument doc = new XmlDocument ();
|
import System
import System.Windows.Forms as SWF
import System.Xml
print "foo"
x = SWF.Form()
doc = XmlDocument()
|
JScript doesn't use namespaces.
|
|
|
|
readonly int X = 2;
const int Y = 3;
|
final X = 2
static final Y = 3
|
There are no constants or read-only variables in JScript.
|