Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

appkr appkr

🎯
Focusing
View GitHub Profile
@appkr
appkr / jsbin.gepage.js
Last active Aug 29, 2015
JavaScript This Keyword// source http://jsbin.com/gepage
View jsbin.gepage.js
// "this" keyword
var makeRequest = function(url, callback) {
var data = 10; // Ajax
callback(data);
};
var obj = {
someValue : 20,
loadData: function(data) {
var sum = this.someValue + data;
@appkr
appkr / jsbin.muraqe.js
Last active Aug 29, 2015
JavaScript Data & Accessor// source http://jsbin.com/muraqe
View jsbin.muraqe.js
var createPerson = function(firstName, lastName) {
var person = {};
Object.defineProperties(person, {
firstName : {
value : firstName,
enumerable : true
},
lastName : {
value : lastName,
@appkr
appkr / jsbin.mawohi.js
Last active Aug 29, 2015
JavaScript Parachutic Inheritance// source http://jsbin.com/mawohi
View jsbin.mawohi.js
var createPerson = function(firstName, lastName) {
var person = {
firstName : firstName,
lastName : lastName,
sayHello : function () {
return "Hi there?";
}
};
Object.defineProperty(person, "fullName", {
@appkr
appkr / jsbin.hiteva.js
Last active Aug 29, 2015
JavaScript Prototypal Inheritance// source http://jsbin.com/hiteva
View jsbin.hiteva.js
var Person = function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
};
Object.defineProperties(Person.prototype, {
sayHi : {
value : function () {
return "Hi there";
},
@appkr
appkr / jsbin.xuvoga.js
Last active Aug 29, 2015
JavaScript Constructor// source http://jsbin.com/xuvoga
View jsbin.xuvoga.js
var Person = function(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
};
// every object from Person has below properties.
Object.defineProperties(Person.prototype, {
sayHi : {
value : function () {
return "Hi there ?";
@appkr
appkr / jsbin.kipame.js
Last active Aug 29, 2015
JavaScript Event Target// source http://jsbin.com/kipame
View jsbin.kipame.js
var EventTarget = function() {
Object.defineProperty(this, "__listeners", {
value: {}
});
};
Object.defineProperties(EventTarget.prototype, {
addListener: {
value: function(type, listener) {
if (typeof this.__listeners[type] === "undefined") {
@appkr
appkr / jsbin.noveqe.css
Last active Aug 29, 2015
JavaScript Toolbar Example - Add Event// source http://jsbin.com/noveqe
View jsbin.noveqe.css
.toolbar {
background-color: #c6c6c6;
/*height: 50px;*/
padding: 5px;
}
.toolbar-item {
display: inline-block;
height: 50px;
width: 50px;
@appkr
appkr / jsbin.qofali.js
Last active Aug 29, 2015
JavaScript Protytypal Inheritance 2 from CodeSchool// source http://jsbin.com/qofali
View jsbin.qofali.js
var Shoe = function(shoeSize, shoeColor, forGender, constructStyle) {
this.size = shoeSize;
this.color = shoeColor;
this.gender = forGender;
this.construction = constructStyle;
};
Shoe.prototype = {
putOn: function() {
alert("Your " + this.construction + "'s " + "on, dude!");
@appkr
appkr / jsbin.posusi.js
Last active Aug 29, 2015
JavaScript Method Overriding// source http://jsbin.com/posusi
View jsbin.posusi.js
Number.prototype.numberFormat = function (){
return this.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
};
Object.prototype.getName = function() {
var funcNameRegex = /function (.{1,})\(/;
var results = (funcNameRegex).exec((this).constructor.toString());
return (results && results.length > 1) ? results[1] : "";
};
@appkr
appkr / jsbin.lapaca.js
Last active Aug 29, 2015
JavaScript Ticketing Example// source http://jsbin.com/lapaca
View jsbin.lapaca.js
var parkRides = [
["Birch Bumper", 40],
["Pines Plunge", 55],
["Cedar Coaster", 20],
["Ferries Whell of Fires", 90]
];
var fastPassQueue = [
"Cedar Coaster",
"Pines Plunge",