Skip to content

Instantly share code, notes, and snippets.

View deepakkj's full-sized avatar
🎯
Focusing

Deepak Kumar Jain deepakkj

🎯
Focusing
View GitHub Profile
@deepakkj
deepakkj / prototypal_inheritance.js
Created February 23, 2016 10:03
Prototypal Inheritance in Javascript
//prototypal inheritance
//parent
var human = {
species: "human",
create: function(values) {
var instance = Object.create(this);
Object.keys(values).forEach(function(key) {
instance[key] = values[key];
});
@deepakkj
deepakkj / classical_inheritance.js
Created February 23, 2016 09:54
Classical Inheritance in Javascript
//parent
var Person = function(firstName){
this.firstName = firstName;
};
Person.prototype.walk = function(){
console.log("I am walking.");
};
Person.prototype.sayHello = function(){
@deepakkj
deepakkj / method-property.js
Created February 22, 2016 13:48
Methods are bound to an object as a property : Invoking methods which are 'out-of-context'
//creating a class named Person with a constructor
var Person = function(firstName){
this.firstName = firstName;
};
//creating prototpye function to access it, with multiple objects while it is loaded only once in memory
Person.prototype.sayHello = function(){
console.log("My name is " + this.firstName);
};
@deepakkj
deepakkj / js_oops.js
Created February 22, 2016 13:28
Javascript - Namespace, Objects, Class, Constructors, Properties
<script type='text/javascript'>//<![CDATA[
window.onload=function(){
// create a global object namd myapp by checking if thre exists a another same object in the same file or another filw.
//It it exists then assign that object to the new object or else create a new object with empty methods, functions and variables.
//global namespace
var myapp = myapp || {};
//sub-namespace
myapp.event = {
@deepakkj
deepakkj / JSON.html
Created September 17, 2015 16:50
Display JSON data in HTML
<!-- Display JSON data in HTML -->
<!-- This is an example to show simple JSON data in a HTML page -->
<!-- Author: Deepak Kumar Jain -->
<!-- Email me at [email protected] -->
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[Display JSON data in HTML]">
<meta charset="utf-8">
package uk.ac.reading.sis05kol.mooc;
//Other parts of the android libraries that we use
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
public class TheGame extends GameThread{
//Will store the image of a ball