Example 2: | |
Input: | |
/*myname | |
var numIsNaN = function(v){ | |
if(typeof v !== 'number' || isNaN(v)){ | |
throw new TypeError('NaN: ' + v); | |
} | |
return v; | |
}; | |
*/ | |
function Vector(x, y){ | |
/*vecNaN x*/ | |
/*vecNaN y*/ | |
this.x = x; | |
this.y = y; | |
} | |
Compiled with: | |
jsdev < test.js myname vecNaN:numIsNaN | |
Outputs: | |
{ var numIsNaN = function(v){ | |
if(typeof v !== 'number' || isNaN(v)){ | |
throw new TypeError('NaN: ' + v); | |
} | |
return v; | |
};} | |
function Vector(x, y){ | |
{numIsNaN(x);} | |
{numIsNaN(y);} | |
this.x = x; | |
this.y = y; | |
} |
Example 3: | |
Input: | |
function Vector(x, y){ | |
/*nonZero(x === 0) 'x was zero'*/ | |
/*nonZero(y === 0) 'y was zero'*/ | |
this.x = x; | |
this.y = y; | |
} | |
Compiled with: | |
jsdev < test.js myname nonZero:alert | |
Outputs: | |
function Vector(x, y){ | |
{if(x === 0) alert('x was zero');} | |
{if(y === 0) alert('y was zero');} | |
this.x = x; | |
this.y = y; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment