Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created March 11, 2015 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/026a536093fee5fc1a3f to your computer and use it in GitHub Desktop.
Save shigemk2/026a536093fee5fc1a3f to your computer and use it in GitHub Desktop.
// 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