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 instanceOf functionality. |
||
9 | */ |
||
10 | test('ClassBuilder:InstanceOfTest', function(assert) { |
||
11 | |||
12 | var cEmpty = JOII.ClassBuilder({}); |
||
0 ignored issues
–
show
|
|||
13 | var c1 = new cEmpty(); |
||
14 | assert.strictEqual(c1.instanceOf(cEmpty), true, 'c1 is an instance of cEmpty'); |
||
15 | |||
16 | var cChild = JOII.ClassBuilder({'extends': cEmpty}, {}); |
||
17 | var c2 = new cChild(); |
||
18 | assert.strictEqual(c2.instanceOf(cEmpty), true, 'c2 is an instance of cEmpty'); |
||
19 | assert.strictEqual(c2.instanceOf(cChild), true, 'c2 is an instance of cChild'); |
||
20 | |||
21 | var cChild2 = JOII.ClassBuilder({'extends': cEmpty}, {}); |
||
22 | var c3 = new cChild2(); |
||
23 | assert.strictEqual(c3.instanceOf(cEmpty), true, 'c3 is an instance of cEmpty'); |
||
24 | assert.strictEqual(c3.instanceOf(cChild), false, 'c3 is NOT an instance of cChild'); |
||
25 | assert.strictEqual(c3.instanceOf(cChild2), true, 'c3 is an instance of cChild2'); |
||
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.