Skip to content

Instantly share code, notes, and snippets.

@rishabhmhjn
rishabhmhjn / node_install_with_nvm.sh
Last active December 18, 2015 04:39
Install nodejs using nvm
vi ~/.bashrc
# [add the following]
# -------------------------------------------------------------
. ~/.nvm/nvm.sh && nvm use default
# -------------------------------------------------------------
mkdir ~/src
cd !$
@rishabhmhjn
rishabhmhjn / JS.inheritance.js
Created May 31, 2013 06:57
Javascript inheritance
var Person = function () {
this.fname = 'douglas';
this.lname = 'crockford';
};
var Student = function() {
return this;
};
Student.prototype = new Person();
@rishabhmhjn
rishabhmhjn / Array.myLast.js
Last active December 17, 2015 17:58
Encapsulating Array Object to add a custom method
var MyArray = function() { return this; } ;
MyArray.prototype = new Array();
MyArray.prototype.constructor = MyArray; // http://stackoverflow.com/a/10430875/842214
Object.defineProperty(MyArray.prototype, 'myLast', (function () {
return {
configurable : true,
enumerable : true,
get : function () {
return this[this.length - 1];