Pure js extend function