-
-
Save kirbysayshi/1712319 to your computer and use it in GitHub Desktop.
JSDev examples
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
Example 1: | |
Input: | |
/*myname | |
console.log('what what'); | |
*/ | |
Compiled with: | |
jsdev < test.js myname | |
Outputs: | |
{ console.log('what what'); } | |
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
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; | |
} |
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
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