Created
May 3, 2016 13:00
-
-
Save anonymous/a2045bbaeb355e0c3f09cfb6aab1d6f8 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/yazozum
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| //ForEach | |
| "use strict"; | |
| [1, 2, 3].forEach(function (x) { | |
| return console.log(x); | |
| }); | |
| //Map | |
| [1, 2, 3].map(function (x) { | |
| return x + 1; | |
| }); | |
| //Filter [returns a boolean,applying test to each elem] | |
| [1, 2, 3].filter(function (x) { | |
| return x > 1; | |
| }); | |
| //concatAll [not in ES6] | |
| [[1], [2, 3], [], [4]].concatAll(); //[1,2,3,4] | |
| // Top-rated Movies Colleciton | |
| var getTopRatedFilms = function getTopRatedFilms(user) { | |
| return user.videoLists.map(function (videoList) { | |
| return videoList.videos.filter(function (video) { | |
| return video.rating === 5.0; | |
| }); | |
| }).concatAll(); | |
| }; | |
| getTopRatedFilms(user).forEach(function (film) { | |
| return console.log(film); | |
| }); | |
| //Mouse Drags collection [Top-rated Movies Colleciton] | |
| var getElementDrags = function getElementDrags(elmt) { | |
| return elmt.mouseDowns.map(function (mouseDown) { | |
| return document.mouseMoves.takeUntil(document.mouseUps); | |
| }).concatAll(); | |
| }; | |
| getElementDrags(image).forEach(function (pos) { | |
| return image.position = pos; | |
| }); | |
| // Introducing Observable | |
| Observable === Collections + Time; | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">//ForEach | |
| [1,2,3].forEach(x => console.log(x)); | |
| //Map | |
| [1,2,3].map(x => x + 1); | |
| //Filter [returns a boolean,applying test to each elem] | |
| [1,2,3].filter(x => x > 1); | |
| //concatAll [not in ES6] | |
| [[1],[2,3],[],[4]].concatAll()//[1,2,3,4] | |
| // Top-rated Movies Colleciton | |
| var getTopRatedFilms = user => | |
| user.videoLists. | |
| map(videoList => | |
| videoList.videos. | |
| filter(video => video.rating === 5.0)). | |
| concatAll(); | |
| getTopRatedFilms(user). | |
| forEach(film => console.log(film)); | |
| //Mouse Drags collection [Top-rated Movies Colleciton] | |
| var getElementDrags = elmt => | |
| elmt.mouseDowns. | |
| map(mouseDown => | |
| document.mouseMoves. | |
| takeUntil(document.mouseUps)). | |
| concatAll(); | |
| getElementDrags(image). | |
| forEach(pos => image.position = pos); | |
| // Introducing Observable | |
| Observable === Collections + Time | |
| </script></body> | |
| </html> |
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
| //ForEach | |
| "use strict"; | |
| [1, 2, 3].forEach(function (x) { | |
| return console.log(x); | |
| }); | |
| //Map | |
| [1, 2, 3].map(function (x) { | |
| return x + 1; | |
| }); | |
| //Filter [returns a boolean,applying test to each elem] | |
| [1, 2, 3].filter(function (x) { | |
| return x > 1; | |
| }); | |
| //concatAll [not in ES6] | |
| [[1], [2, 3], [], [4]].concatAll(); //[1,2,3,4] | |
| // Top-rated Movies Colleciton | |
| var getTopRatedFilms = function getTopRatedFilms(user) { | |
| return user.videoLists.map(function (videoList) { | |
| return videoList.videos.filter(function (video) { | |
| return video.rating === 5.0; | |
| }); | |
| }).concatAll(); | |
| }; | |
| getTopRatedFilms(user).forEach(function (film) { | |
| return console.log(film); | |
| }); | |
| //Mouse Drags collection [Top-rated Movies Colleciton] | |
| var getElementDrags = function getElementDrags(elmt) { | |
| return elmt.mouseDowns.map(function (mouseDown) { | |
| return document.mouseMoves.takeUntil(document.mouseUps); | |
| }).concatAll(); | |
| }; | |
| getElementDrags(image).forEach(function (pos) { | |
| return image.position = pos; | |
| }); | |
| // Introducing Observable | |
| Observable === Collections + Time; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment