Skip to content

Instantly share code, notes, and snippets.

@eshacker
eshacker / title_casing_a_normal_string.js
Last active December 19, 2015 14:25
Title Casing A Normal String
var str = "the quick brown fox jumped over the lazy dog";
var arr = str.split(' ');
var titleArr = arr.map(function(x){
return x.charAt(0).toUpperCase() + x.slice(1);
});
var titleStr = titleArr.join(' ');
console.log(titleStr);
@eshacker
eshacker / wrong_vs_right_oo_in_js.js
Last active March 2, 2016 07:24
Wrong versus right way to do OO in JS
/* Reading https://drboolean.gitbooks.io/mostly-adequate-guide/content/ch1.html
* I have a differing opinion. Please help in sorting it out.
*/
// Original code : or I think wrong way to to Object Oriented code.
var Flock = function(n) {
this.seagulls = n;
};
@eshacker
eshacker / obj_ref_play.2015.Dec.19.js
Created December 19, 2015 01:22
Playing with obj reference in javascript
// Using stricter env
'use strict';
// our object; does only one thing.
var obj = {
getMe: function() {
return this;
}