Skip to content

Instantly share code, notes, and snippets.

View cyb3rD's full-sized avatar

Nikolay Ignatev cyb3rD

View GitHub Profile
@cyb3rD
cyb3rD / functional-programming.js
Created September 13, 2016 14:12
Example of functional programmimg with JavaScript
/**
* Helper functions
*/
// Map array elements with functions
var mapForEach = function(arr, fn) {
var newArr = [];
for (var i=0; i< arr.length; i++) {
newArr.push(
fn(arr[i]) // pass array item element to the function
@cyb3rD
cyb3rD / closure-factory.js
Created September 13, 2016 10:54
Factory example
function createVehicle(vehicleType){
return function(brand) {
if (vehicleType === 'Car') {
console.log('Achieve New Car! Brand:' + brand);
}
if (vehicleType === 'Truck') {
@cyb3rD
cyb3rD / closure-example.js
Last active September 13, 2016 10:09
Sample closure understanding code
//Closure example
function greet(whatToSay) {
// get value back when invoke function
// get back function
return function(name) {
console.log(whatToSay + ' ' + name);
};
}
@cyb3rD
cyb3rD / gist:7f4dd4953a507fbcf4050a7e85ed0d24
Created July 12, 2016 13:33 — forked from getify/gist:5285514
since `let (foo = 42) { ... }` is not coming to ES6 after all...

I hereby propose this form of let usage as the next best option, since the clearly better let (foo = 42) { ... } let-block-statement syntax is dead and not coming to ES6:

/*let*/ { let foo = 42;

   // your code that uses `foo`

}
@cyb3rD
cyb3rD / js-courses.md
Created June 19, 2016 13:35 — forked from alexbaumgertner/js-courses.md
JavaScript courses as on March 2016
@cyb3rD
cyb3rD / Simple hover effect.markdown
Last active October 8, 2015 13:31
Simple hover effect
@cyb3rD
cyb3rD / Sample LoginForm.markdown
Created June 10, 2015 13:27
Sample LoginForm