Created
March 11, 2015 15:36
-
-
Save shigemk2/026a536093fee5fc1a3f 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
// https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Statements/with | |
// SyntaxError: Strict mode code may not include a with statement | |
"use strict"; | |
var a, x, y; | |
var r = 10; | |
// ネームスペースを束縛して省略する | |
// Pythonでいうところのfrom math import * | |
with (Math) { | |
a = PI * r * r; | |
x = r * cos(PI); | |
y = r * sin(PI / 2); | |
} | |
// a = Math.PI * r * r; | |
// x = r * Math.cos(Math.PI); | |
// y = r * Math.sin(Math.PI / 2); | |
console.log(a); | |
console.log(x); | |
console.log(y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment