This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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]; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//parent | |
var Person = function(firstName){ | |
this.firstName = firstName; | |
}; | |
Person.prototype.walk = function(){ | |
console.log("I am walking."); | |
}; | |
Person.prototype.sayHello = function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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 = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder