1 | 'use strict'; |
||
2 | require('../../dist/joii.min.js'); |
||
3 | |||
4 | /** |
||
5 | * JOII supports 3 ways of declaring visibility on a property of method: public |
||
6 | * protected and private. |
||
7 | * |
||
8 | * public : The method is accessible from outside the scope of the class |
||
9 | * once instantiated. Properties that are not functions are never |
||
10 | * accessible but will have public getters and setters generated |
||
11 | * for them. |
||
12 | * |
||
13 | * protected : Same as public, but the getters and setters are only accessible |
||
14 | * from within the scope of the class or any inheriting classes. |
||
15 | * |
||
16 | * private : Not accessible from the outside. Properties declared private |
||
17 | * will NOT have getter/setter methods generated. Please note that |
||
18 | * unlike other OOP-like languages, private methods and properties |
||
19 | * ARE accessible in inherited classes. |
||
20 | */ |
||
21 | var MyClass = Class({ |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
22 | |||
23 | // When no meta-data is used when declaring a property, it defaults to |
||
24 | // 'public' visibility with no type-checking. The following methods are |
||
25 | // being generated automatically: getSomeProperty() and setSomeProperty(). |
||
26 | some_property: 'Hello World', |
||
27 | |||
28 | // This does exactly the same: |
||
29 | 'public some_property': 'Hello World', |
||
30 | |||
31 | // The same goes for methods: |
||
32 | someMethod: function () { |
||
33 | // ... do stuff. |
||
34 | }, |
||
35 | |||
36 | // Is the same as: |
||
37 | 'public someMethod' : function () { |
||
38 | // ... do stuff. |
||
39 | } |
||
40 | }); |
||
41 |