1 | /* Javascript Object Inheritance Implementation ______ ________ |
||
2 | * (c) 2016 <[email protected]> __ / / __ \/ _/ _/ |
||
3 | * Licensed under MIT. / // / /_/ // /_/ / |
||
4 | * ------------------------------------------------------ \___/\____/___/__*/ |
||
5 | var JOII = require('../../dist/joii').JOII; |
||
6 | |||
7 | /** |
||
8 | * Tests visibility and accessibility of properties. |
||
9 | */ |
||
10 | test('ClassBuilder:VisibilityTest', function(assert) { |
||
11 | |||
12 | // Base class definition. |
||
13 | var VisibilityTestClass = JOII.ClassBuilder({}, { |
||
0 ignored issues
–
show
|
|||
14 | 'protected number a' : 1, |
||
15 | 'protected function test' : function() { |
||
16 | return this.a; |
||
17 | }, |
||
18 | 'public function runTest': function() { |
||
19 | return this.test(); |
||
20 | } |
||
21 | }); |
||
22 | |||
23 | var t = new VisibilityTestClass(); |
||
24 | |||
25 | assert.strictEqual(t.runTest(), 1, 'Public function returns protected function result.'); |
||
26 | }); |
||
27 |
Strict mode is a way to opt-in to a restricted variant of JavaScript. It eliminates some common pitfalls by being less lenient and raising more errors.
Besides, it is also used to fix certain mistakes which made it difficult for JavaScript runtimes to perform certain optimizations.
We generally recommend to only enable strict mode on the function scope and not in the global scope as that might break third-party scripts on your website.