Functional Javascript with Ramda - 001

node v8.17.0
version: 1.0.0
endpointsharetweet
// Functions as Data const name = 'Gary Smith'; const f = function sayHello(name) { return 'Hello, ' + name; } console.log(f.name); console.log(f.call(null, name)); f(name);
// Functions as Returned Value const add = x => y => x + y; let add1 = add(1); add1(41);
// Imperative Style const numbersImp = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; function divisibleByTwoImp(arr) { var result = []; for (var i = 0; i < arr.length; i++) { var element = arr[i]; if (element % 2 === 0) { result.push(element); } } return result; } divisibleByTwoImp(numbersImp);
Loading…

no comments

    sign in to comment