Skip to content

Instantly share code, notes, and snippets.

@Sljubura
Sljubura / main.js
Created March 5, 2013 19:56
Decorator pattern
// Constructor
function Sale(price) {
this.price = price || 10
}
Sale.prototype.getPrice = function () {
return this.price;
};
Sale.decorators = {};
Sale.decorators.statetax = {
@Sljubura
Sljubura / secondary.js
Created March 12, 2013 21:44
Strategy pattern
var data = {
first_name: "Vladimir",
last_name: "Sljubura",
age: "unknown",
username: "Slju"
};
validator.config = {
first_name: 'required',
age: 'numeric',
@Sljubura
Sljubura / main.js
Last active December 22, 2015 20:38
Jednostavan prikaz closure-a.
function pdv(OPERACIJA) {
return function (broj) {
if ( OPERACIJA === '-' ) {
return broj - 20;
} else if( OPERACIJA === '+' ) {
return broj + 20;
} else {
throw 'Lose uneti parametri!';
}
}