Skip to content

Instantly share code, notes, and snippets.

@egrueter-dev
egrueter-dev / function-property.js
Created March 4, 2017 16:41
function-property
function fun() {
console.log("hello world");
}
fun();
fun.greeting = "Hello from property";
console.log(fun.greeting) //=> "Hello from property"
@egrueter-dev
egrueter-dev / function-expression.js
Created March 4, 2017 15:34
function-expressions
var myFunction = function [name]([param1[, param2[, ..., paramN]]]) {
statements
};
@egrueter-dev
egrueter-dev / basic-ruby-inheritance.rb
Created March 4, 2017 04:00
basic-ruby-inheritance
class Mammal
def breathe
puts "inhale and exhale"
end
end
class Cat < Mammal
def speak
puts "Meow"
end
@egrueter-dev
egrueter-dev / functional-programming1.js
Last active March 4, 2017 02:54
functional-programming1
function mapForEach(arr, fn) {
const newArr = [];
for (let i=0; i < arr.length; i++) {
newArr.push(
fn(arr[i])
);
};
return newArr;
}
@egrueter-dev
egrueter-dev / proto3.js
Created February 28, 2017 02:20
prototypechain2
// Creating the second prototype
const proto2 = function () {};
proto2.prop3 = "proto 2's property"
// Creating the first prototype
const proto1 = Object.create(proto2)
proto1.prop2 = 'protos property';
const obj = Object.create(proto1);
obj.prop = 'object\'s property';
@egrueter-dev
egrueter-dev / protoypal2.js
Created February 28, 2017 02:15
prototypal-inheritance
// Creating the first prototype
const proto1 = function() {};
proto1.prop2 = 'protos property';
const obj = Object.create(proto1);
obj.prop = 'object\'s property';
console.log(obj.prop);
console.log(obj.prop2);
@egrueter-dev
egrueter-dev / prototypal-inheritance.js
Last active February 28, 2017 02:07
Protoypal Inhertiance 1
const obj = function() {};
obj.prop = 'object\'s property';
console.log(obj.prop);
buttton.addEventListener(‘click, function() {
this.classList.toggle(‘on’); //=> error!!! This is defined globally.
});
const button = document.querySelector(‘.button’);
buttton.addEventListener(‘click, () => {
this.classList.toggle(‘on’); //=> error!!! This is defined globally.
});
const results = winners.map((winner, i) => ({name: winner, race: race, place: i}));