1<script>
2 function f1() {
3 var msg="this is the first program of javascript";
4 document.write("hello "+msg.length);
5 }
6</script>
1JavaScript is a Object-Oriented Programming Language. It is very easy, making it high level.
1/* Spread syntax ( ex. ...arrayName) allows an iterable such as an array expression or string
2to be expanded in places where zero or more arguments (for function calls)
3elements (for array literals) are expected, or an object expression to be
4expanded in places where zero or more key-value pairs (for object literals)
5are expected. */
6
7
8//example
9function sum(x, y, z) {
10 return x + y + z;
11}
1// a simple js class that inherits from
2// a java class
3var TestJs = class extends TestClass {
4 constructor(name) {
5 super(name);
6 }
7
8 ident() {
9 return this.name+' js'
10 }
11}
12
13// a js class that inherits from a
14// js class
15var TestJs2 = class extends TestJs {
16 constructor(name) {
17 super(name);
18 }
19
20 // override js methood
21 ident() {
22 return this.name+' js-2'
23 }
24}
25
26var t = new TestJs2('test');
27
28// call a method from the class itself
29console.log(t.ident());
30// test js-2
31
32// call a property that is inherited
33// from the java object
34console.log(t.name);
35// test