Issues (204)

examples/1.basic/2.constructor.js (1 issue)

Labels
Severity
1
'use strict';
2
require('../../dist/joii.min.js');
3
4
/**
5
 * This class is the same as the one from '1.class.js' but utilizes a
6
 * constructor to immediately set the value of 'some_number'.
7
 */
8
var MyClass = Class({
0 ignored issues
show
Class does not seem to be defined.
Loading history...
9
10
    some_number : 42,
11
12
    construct: function (number) {
13
        this.setSomeNumber(number);
14
    },
15
16
    /**
17
     * Adds the given number to 'some_number'.
18
     * @param number
19
     */
20
    add: function (number) {
21
        this.some_number += number;
22
    }
23
});
24
25
var a = new MyClass(10);
26
27
// Print the current value to the screen. The expected result is 10, because
28
// we passed that number to the constructor.
29
console.log(a.getSomeNumber());
30
31
// Add a number to it.
32
a.add(10);
33
34
// Print it again. The new output is 20.
35
console.log(a.getSomeNumber());
36