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() { | |
| window.UAParserBackup = window.UAParser | |
| }).call(this), | |
| function(t) { | |
| "use strict"; | |
| var e = t.userAgent = function(t) { | |
| function e(t) { | |
| var e = {}, | |
| i = /(dolfin)[ \/]([\w.]+)/.exec(t) || /(chrome)[ \/]([\w.]+)/.exec(t) || /(opera)(?:.*version)?[ \/]([\w.]+)/.exec(t) || /(webkit)(?:.*version)?[ \/]([\w.]+)/.exec(t) || /(msie) ([\w.]+)/.exec(t) || t.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(t) || ["", "unknown"]; | |
| return "webkit" === i[1] ? i = /(iphone|ipad|ipod)[\S\s]*os ([\w._\-]+) like/.exec(t) || /(android)[ \/]([\w._\-]+);/.exec(t) || [i[0], "safari", i[2]] : "mozilla" === i[1] ? /trident/.test(t) ? i[1] = "msie" : i[1] = "firefox" : /polaris|natebrowser|([010|011|016|017|018|019]{3}\d{3,4}\d{4}$)/.test(t) && (i[1] = "polaris"), e[i[1]] = !0, e.name = i[1], e.version = n(i[2]), e |
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 observableStream = Rx.Observable.create(function(observer) { | |
| observer.onNext(1); | |
| }); | |
| var subscriber = observableStream.subscribe(function(data) { | |
| console.log('data', data); | |
| if (data) { | |
| subscriber.dispose(); | |
| } |
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 observableStream = Rx.Observable.create(function (observer) { | |
| var url1 = 'http://hello-universe.com'; | |
| var url2 = 'http://hello-world.com'; | |
| var defaultValue = {}; | |
| observer.onNext(defaultValue); | |
| $.get(url1).then(function(data) { | |
| observer.onNext(data); | |
| return $.get(url2); |
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 PromiseArray = []; | |
| el.addEventListener('scroll', function(e) { | |
| PromiseArray.push(new Promise(...)); | |
| forEachForPromise(); | |
| }); | |
| function forEachForPromises() { | |
| PromiseArray.filter(function(promise) { | |
| promise.then(function(data) { |
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(); | |
| } | |
| }); |
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
| {"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
| 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
| 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 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; | |
| }); |