Skip to content

Instantly share code, notes, and snippets.

@shigemk2 shigemk2/with2.js
Created Mar 11, 2015

Embed
What would you like to do?
// 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
You can’t perform that action at this time.