This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fn = function() { return null; }; | |
| const nan = NaN; | |
| console.log(typeof fn()); // object | |
| console.log(typeof nan); // number :v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fn = function() { return null; }; | |
| const arr = []; | |
| const obj = {}; | |
| console.log(typeof fn); // function | |
| console.log(typeof arr); // object | |
| console.log(typeof obj); // object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const name = 'Bruce'; | |
| const age = 18; | |
| const isDeveloper = true; | |
| console.log(typeof name); // string | |
| console.log(typeof age); // number | |
| console.log(typeof isDeveloper); // boolean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Person (name) { | |
| console.log(this); // Person {} | |
| this.name = name; | |
| } | |
| const bruce = new Person('Bruce'); | |
| console.log(bruce.__proto__); // Person {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Person(){ | |
| this.name = 'Default'; | |
| } | |
| const bruce = Person(); | |
| console.log(bruce.name); // TypeError: Cannot read property 'name' of undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Person() { | |
| this.name = 'Default'; | |
| this.lastname = 'Default'; | |
| } | |
| const bruce = new Person(); | |
| console.log(bruce); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fn = function(){ | |
| // Do something | |
| } | |
| console.log(fn.__proto__.__proto__.__proto__); // null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const person = { | |
| name: 'Anonymous', | |
| lastname: 'Anonymous', | |
| age: 18, | |
| hair: true | |
| } | |
| const developer = { | |
| languages: ['Javascript', 'C#', 'Java'] | |
| } | |
| const esteban = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const developer = { | |
| name: 'Anonymous', | |
| lastname: 'Anonymous', | |
| fullname: function(){ | |
| return this.name + ' ' + this.lastname; | |
| } | |
| } | |
| const bruce = { | |
| name: 'Bruce', | |
| lastname: 'Wayne' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fn = function(name){ | |
| console.log('hello ' + name); | |
| } | |
| const name = fn.name; | |
| const fnCopy = fn.bind(this, 'Bruce'); | |
| fnCopy(); | |
| fn.call(this, 'Bruce'); | |
| fn.apply(this, ['Bruce']); | |
| console.log(fn.toString()); |