Skip to content

Instantly share code, notes, and snippets.

zgangx / jsbin.herifof.js
Last active Sep 16, 2020
Function invocation with apply
View jsbin.herifof.js
//this context change by using apply
var proxy = function(func, thisObject){
return func.apply(thisObject, arguments);
var clicky = {
name: 'my name is proxy',
wasClicked: function(){
View jsbin.miviziy.js
//class emulation adding inheritance
var Class = function(parent){
var klass = function(){
this.init.apply(this, arguments);
// Change klass' prototype
//If a parent is passed to the Class constructor
//we make sure any subclasses share the same prototype.
//creating a temporary anonymous function prevents instances
zgangx / jsbin.catipoz.js
Last active Sep 16, 2020
Javascript Class inheritance using prototype
View jsbin.catipoz.js
//Javascript Class inheritance using prototype
//To subclass a class and inherit its properties
//you need to first define a constructor function.
//Then, you need to assign a new instance of the parent class
//as the prototype for your constructor function
var Animal = function(){};
Animal.prototype.breath = function(){
zgangx / jsbin.jesemabamo.js
Last active Sep 16, 2020
javascript class emulation
View jsbin.jesemabamo.js
//if you call contructor function without new prefix.
//function return undefined and create a global variable name
// = 'bob'
// new prefix is creae a new empty context and switches from global
// to current instance.
//By default, if you don’t return anything from a constructor function
//this—the current context—will be returned.
//Otherwise, you can return any nonprimitive type.
//For example, we could return a function that would set up a new class
View Install composer on Amazon AMI running on EC2
$ cd ~
$ sudo curl -sS | sudo php
$ sudo mv composer.phar /usr/local/bin/composer
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer
then you can run
$ sudo composer install
You can’t perform that action at this time.