Skip to content

Instantly share code, notes, and snippets.

@calvintychan
calvintychan / pureFunctions.js
Created December 4, 2016 22:39
Understanding what pure functions are
// https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-pure-function-d1c076bec976#.8n6883iyc
// Definition of a pure function
// Given the same inputs, a pure function will always return the same output,
// regardless of the number of times the function is called.
// Memorization and pure function goes well togther. Since pure function always return a predicatable value,
// this value can be cache using memorization.
// Non Pure
@calvintychan
calvintychan / functionsDefinitions.js
Created December 2, 2016 15:47
Functions and their scope: declarations vs. expressions
/*
Resources:
- https://javascriptweblog.wordpress.com/2010/07/06/function-declarations-vs-function-expressions/
- http://www.2ality.com/2011/04/ecmascript-5-spec-lexicalenvironment.html
*/
// function declarations uses the VariableEnvironment as scope
function f() {
return 12;
}
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.*;
public class silk extends Sprite
{
public function silk()
{