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
| class Person { | |
| constructor(firstName, lastName) { | |
| this.firstName = firstName; | |
| this.lastName = lastName; | |
| } | |
| hello () { | |
| console.log(`My name is ${this.firstName} ${this.lastName}`); | |
| } | |
| } |
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
| class Developer extends Person { | |
| constructor (firstName, lastName, role) { | |
| super(firstName, lastName); | |
| this.role = role; | |
| } | |
| hello () { | |
| console.log(`My name is ${this.firstName} ${this.lastName} and I am a ${this.role}`); | |
| } | |
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 listen(element, eventName) { | |
| return new Observable(observer => { | |
| // Create an event handler which sends data to the sink | |
| let handler = event => observer.next(event); | |
| // Attach the event handler | |
| element.addEventListener(eventName, handler, true); | |
| // Return a function which will cancel the event stream | |
| return () => { |
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
| var btn = document.getElementById('button'); | |
| btn.addEventListener('click', function () { | |
| console.log('Hello, Universe'); | |
| }); |
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
| var arr = [1, 2, 3, 4, 5, 6]; | |
| var filteredArr = arr.filter(function(item) { | |
| return item % 2 === 0; | |
| }); | |
| var mappedFilteredArr = filteredArr.map(function (item) { | |
| return item * 2; | |
| }); |
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
| el.addEventListener('scroll', function () { | |
| if (pageYOffset !== 0) { | |
| realCallback(); | |
| } | |
| }); | |
| el.addEventListener('touchmove', function () { | |
| if (pageYOffset !== 0) { | |
| realCallback(); | |
| } |
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
| var btn = document.getElementById('button'); | |
| btn.addEventListener('click', function () { | |
| if (window.__VALID_USER__) { | |
| console.log('Hello, Universe'); | |
| } | |
| }); |
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
| {"answers":["function(console) {\n\tvar names = [\"Ben\", \"Jafar\", \"Matt\", \"Priya\", \"Brian\"],\n\t\tcounter;\n\n\tfor(counter = 0; counter < names.length; counter++) {\n\t\tconsole.log(names[counter]);\n\t}\n}\n\t\t","function(console) {\n\tvar names = [\"Ben\", \"Jafar\", \"Matt\", \"Priya\", \"Brian\"];\n\n\tnames.forEach(function(name) {\n\t\tconsole.log(name);\n\t});\n}\n\t\t","function() {\n\tvar newReleases = [\n\t\t{\n\t\t\t\"id\": 70111470,\n\t\t\t\"title\": \"Die Hard\",\n\t\t\t\"boxart\": \"http://cdn-0.nflximg.com/images/2891/DieHard.jpg\",\n\t\t\t\"uri\": \"http://api.netflix.com/catalog/titles/movies/70111470\",\n\t\t\t\"rating\": [4.0],\n\t\t\t\"bookmark\": []\n\t\t},\n\t\t{\n\t\t\t\"id\": 654356453,\n\t\t\t\"title\": \"Bad Boys\",\n\t\t\t\"boxart\": \"http://cdn-0.nflximg.com/images/2891/BadBoys.jpg\",\n\t\t\t\"uri\": \"http://api.netflix.com/catalog/titles/movies/70111470\",\n\t\t\t\"rating\": [5.0],\n\t\t\t\"bookmark\": [{ id: 432534, time: 65876586 }]\n\t\t},\n\t\t{\n\t\t\t\"id\": 654 |
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
| el.addEventListener('scrollWhenScrollNotAtTop', realCallback); | |
| $.ajax('http://get-user-info.com').ifUserDidPay(showSomethingColl); |
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
| $.get('http://get-user-info.com').then(function(user) { | |
| if (user.didPay) { | |
| showSomethingCool(); | |
| } | |
| }); |