Last active
August 29, 2015 13:56
-
-
Save cflove/9279029 to your computer and use it in GitHub Desktop.
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"> | |
// function CookRice(){ | |
// alert(“hello”) | |
// } | |
// --------------------------- | |
// Var CookRice = function() { | |
// alert(“hello”) | |
// } | |
// --------------------------- | |
// Var CookRice = function() { | |
// alert(“hello”) | |
// } | |
// CookRice() | |
// --------------------------- | |
// Var CookRice = function() { | |
// alert(“hello”) | |
// }() | |
// --------------------------- | |
// CookRice = function(rice,water,heat) { | |
// var ricepot = rice+water | |
// var cookedrice = ricepot+heat | |
// alert( cookedrice) | |
// } | |
// CookRice(1,1,100) | |
// --------------------------- | |
// CookRice = function(rice,water,heat) { | |
// var ricepot = rice+water | |
// var cookedrice = ricepot+heat | |
// if ( cookedrice == 102 ) { | |
// return 'cooked_rice' | |
// } { | |
// return 'rice_is_spoiled' | |
// } | |
// } | |
// RicePlate = CookRice(1,1,100) | |
// alert(RicePlate) | |
//------------------------------ | |
// CookRice = function() { | |
// var rice = arguments[0] | |
// var water = arguments[1] | |
// var heat = arguments[2] | |
// var ricepot = rice+water | |
// var cookedrice = ricepot+heat | |
// if ( cookedrice == 102 ) { | |
// return 'cooked_rice' | |
// } { | |
// return 'rice_is_spoiled' | |
// } | |
// } | |
// RicePlate = CookRice(1,1,100) | |
// alert(RicePlate) | |
//------------------------------ | |
// kitchen = { | |
// oven : 'on', | |
// plates : 'washed' | |
// } | |
// console.log(kitchen) | |
// alert(kitchen.oven) | |
//------------------------------ | |
// kitchen = { | |
// oven : 'on', | |
// plates : 'washed', | |
// CookRice : function() { | |
// console.log(this) | |
// var rice = arguments[0] | |
// var water = arguments[1] | |
// var heat = arguments[2] | |
// var ricepot = rice+water | |
// var cookedrice = ricepot+heat | |
// if ( cookedrice == 102 ) { | |
// return 'cooked_rice' | |
// } { | |
// return 'rice_is_spoiled' | |
// } | |
// } | |
// } | |
// RicePlate = kitchen.CookRice(1,1,100) | |
// alert(RicePlate) | |
//------------------------------ | |
// kitchen = { | |
// oven : 'on', | |
// plates : 'washed', | |
// CookRice : function(rice,water,heat) { | |
// var ricepot = rice+water | |
// var cookedrice = ricepot+heat | |
// if ( cookedrice == 102 && this.oven == 'on') { | |
// return 'cooked_rice' | |
// } { | |
// return 'rice_is_spoiled' | |
// } | |
// } | |
// } | |
// RicePlate = kitchen.CookRice(1,1,100) | |
// alert(RicePlate) | |
//------------------------------ | |
// kitchen = { | |
// oven : 'on', | |
// plates : 'washed', | |
// CookRice : function(rice,water,heat) { | |
// var ricepot = rice+water | |
// var cookedrice = ricepot+heat | |
// if ( cookedrice == 102 && this.oven == 'on') { | |
// return 'cooked_rice' | |
// } { | |
// return 'rice_is_spoiled' | |
// } | |
// } | |
// } | |
// kitchen.oven = 'off' | |
// RicePlate = kitchen.CookRice(1,1,100) | |
// alert(RicePlate) | |
//------------------------------ | |
// kitchen = { | |
// oven : 'on', | |
// plates : 'washed', | |
// CookRice : function(rice,water,heat) { | |
// var ricepot = rice+water | |
// var cookedrice = ricepot+heat | |
// if ( cookedrice == 102 && this.oven == 'on') { | |
// this.oven ="off" | |
// return 'cooked_rice' | |
// } { | |
// return 'rice_is_spoiled' | |
// } | |
// } | |
// } | |
// RicePlate = kitchen.CookRice(1,1,100) | |
// alert(RicePlate) | |
// RicePlate = kitchen.CookRice(1,1,100) | |
// alert(RicePlate) | |
//------------------------------ | |
// kitchen = { | |
// oven : 'on', | |
// plates : 'washed', | |
// CookRice : function() { | |
// var milk = 'no' | |
// console.dir(this) | |
// } | |
// } | |
// var myCooking = new kitchen.CookRice | |
// myCooking.milk = 'no' | |
// var grandmaCooking = new kitchen.CookRice | |
// grandmaCooking.milk = 'yes' | |
//------------------------------ | |
// kitchen = { | |
// oven : 'on', | |
// plates : 'washed', | |
// CookRice : function() { | |
// var milk = 'no' | |
// console.dir(this) | |
// } | |
// } | |
// function addmilk() { | |
// this.milk = 'yes' | |
// } | |
// kitchen.CookRice.prototype.addmilk = addmilk | |
// var myCooking = new kitchen.CookRice | |
// myCooking.addmilk() | |
// var grandmaCooking = new kitchen.CookRice | |
//------------------------------ | |
// CookRice = function() { | |
// console.dir(this) | |
// } | |
// function addmilk(i) { | |
// this.milk = i | |
// } | |
// CookRice.prototype.addmilk = addmilk | |
// var myCooking = new CookRice | |
// myCooking.addmilk('yes') | |
// myCooking.rice = "1" | |
// myCooking.water = "1" | |
// myCooking.heat = "100" | |
//------------------------------ | |
// CookRice = function() { | |
// console.dir(this) | |
// } | |
// function addmilk() { | |
// if(this.rice == 1) { | |
// this.milk = 1 | |
// } else { | |
// this.milk = 0 | |
// } | |
// } | |
// CookRice.prototype.addmilk = addmilk | |
// var myCooking = new CookRice | |
// myCooking.rice = "2" | |
// myCooking.water = "1" | |
// myCooking.heat = "100" | |
// myCooking.addmilk() | |
//------------------------------ | |
// CookRice = function() { | |
// console.dir(this) | |
// } | |
// CookSoup = function() { | |
// console.dir(this) | |
// } | |
// function addmilk() { | |
// if(this.rice == 1) { | |
// this.milk = 1 | |
// } else { | |
// this.milk = 0 | |
// } | |
// } | |
// CookRice.prototype.addmilk = addmilk | |
// CookSoup.prototype.addmilk = addmilk | |
// var myCooking = new CookRice | |
// myCooking.rice = "2" | |
// myCooking.water = "1" | |
// myCooking.heat = "100" | |
// myCooking.addmilk() | |
// var SoupPot = new CookSoup | |
// SoupPot.rice = "2" | |
// SoupPot.water = "1" | |
// SoupPot.heat = "100" | |
// SoupPot.addmilk() | |
//------------------------------ | |
// CookRice = function(a,b,c) { | |
// console.dir(this) | |
// console.dir(arguments) | |
// return this.rice | |
// } | |
// var ingreedients = {rice:1,water:1,heat:100} | |
// CookRice(1,2,3) // This is the parent object, happened to be the window | |
// // this become the current (this) object and we can values to this | |
// CookRice.call(ingreedients,1,2,3) //arguments pass as a list in each position | |
// CookRice.apply(ingreedients,[1,2,3]) //arguments pass as array | |
//------------------------------ | |
// Kitchen = function() { | |
// this.Souppot = 0 | |
// this.Ricepot = 0 | |
// } | |
// Kitchen.prototype.riceCooker = function(){ | |
// if (this.rice >= 1 && this.water >= 2) { | |
// this.Ricepot = this.Ricepot + 3 | |
// this.rice = this.rice - 1 | |
// this.water = this.water - 2 | |
// } else { | |
// alert('Not enough ingredients to cook rice ') | |
// } | |
// } | |
// Kitchen.prototype.SoupCooker = function() { | |
// if (this.rice >= 1 && this.water >= 4 && this.chicken >= 1) { | |
// this.Souppot = this.Souppot+6 | |
// this.rice = this.rice - 1 | |
// this.water = this.water - 4 | |
// this.chicken = this.chicken - 1 | |
// } else { | |
// alert('Not enough ingredients to cook soup ') | |
// } | |
// } | |
// var myKitchen = new Kitchen | |
// myKitchen.rice = 10 | |
// myKitchen.water = 10 | |
// myKitchen.chicken = 1 | |
// myKitchen.riceCooker() | |
// myKitchen.SoupCooker() | |
// alert(myKitchen.Souppot) | |
//------------------------------ | |
// x = 1 | |
// a = function() { | |
// console.log(x) | |
// var x = "hello" | |
// }() | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment