Published
Edited
Aug 16, 2018
2 stars
Insert cell
md`# Javascript Functional Programming by Example

http://www.labri.fr/perso/renault/working/research/files/jdev2015.0.pdf


`
Insert cell
md `## anonymous functions `
Insert cell
{
var plus = function (x , y ) { return x + y };
return plus (4 ,5) // → 9
}
Insert cell
Insert cell
{
function createClosure () {
var noDirectAccess = 'secret';
return function () {
return noDirectAccess
}
}
var showSecret = createClosure ();
// noDirectAccess is not defined
// but showSecret can still reach it
return showSecret()// → secret

}
Insert cell
md `## Currying / Partial application `
Insert cell
{
function plus_curry ( x ) {
return function ( y ) {
return x + y }
}
return plus_curry (4)(5) //+
}
Insert cell
Insert cell
myModule = {
var myModule = ( function () {
var conf = { // Private to the function
useCaching : true ,
language : 'en'
};
return {
reportConfig : function () {
return 'Caching ' + ( conf . useCaching ? 'enabled ' : 'disabled ');

} ,
updateCaching : function ( caching ) {
conf . useCaching = caching ; } // Restricted access to config
}})();
return myModule
}
Insert cell
myModule.reportConfig()
Insert cell
{

function plucker ( field ) {
return function ( obj ) {
return ( obj && obj [ field ]);
};}

var oldies = [
{ name : "pim" , color : "green"} ,
{ name : "pam" , color : "red "} ,
{ name : "poum ", color : "blue" }];

return oldies.map( plucker ("name")) + " : " + oldies.map( plucker ("color"))

}
Insert cell
md `## arrow functions

https://www.sitepoint.com/es6-arrow-functions-new-fat-concise-syntax-javascript/`
Insert cell
// ES6
multiplyES6 = (x, y) => { return x * y }
Insert cell
multiplyES6(5, 42)
Insert cell
//ES6
docLogEs6 = () => { return document}

Insert cell
Insert cell
md `# ES6 References
http://es6-features.org/#Constants

https://www.w3schools.com/js/js_es6.asp

https://medium.freecodecamp.org/write-less-do-more-with-javascript-es6-5fd4a8e50ee2

http://exploringjs.com/

https://github.com/zsolt-nagy/es6-summary

https://codeburst.io/es6-tutorial-for-beginners-5f3c4e7960be

http://ccoenraets.github.io/es6-tutorial/

`
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more