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
""" | |
Exports Issues from a specified repository to a CSV file | |
Uses basic authentication (Github username + password) to retrieve Issues | |
from a repository that username has access to. Supports Github API v3. | |
""" | |
import csv | |
import requests | |
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
var x = function(){} //名前のない関数を生成し、変数xに代入している。 | |
var x = new Function("console.log('lalala')") //組み込み関数Functionから、console.logの処理を持つ無名関数を生成し、変数xに代入している。jsの全ての関数は組み込み関数Functionを継承する。 | |
x //=>function anonymous(){console.log('lalala')}を返す。 | |
x() //=>lalala undefined を返す。xに代入された無名関数を実行した。jsの全ての関数はデフォルトで値を返す仕様だが、返り値が定義されていない場合は、undefinedを返す。 |
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
function x(){console.log('lululu')}; //=>undefined | |
function y(func){func();}; //=>undefined | |
y(x); //lululu undefined を返す。関数xを引数として、関数yを呼び出している。 | |
y(function(){console.log('lalala');};) //=>lalala undefinedを返す。無名関数も引数として渡すことができる。 | |
function x(){return function(){ //戻り値に無名関数を返すように定義している。 | |
console.log('lalala'); | |
}; | |
}; | |
var y = x(); //変数yに関数xの実行結果を代入する。実行結果は関数xの戻り値である無名関数である。 |
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
var scope = 'lalala'; //グローバル変数を定義する。scriptのどこからでも参照できる。 | |
function x(){ //ローカル変数local、グローバル変数globalを定義する。関数内でvarをつけずに定義すると、グローバル変数になる。 | |
var local = 'local'; | |
global = 'global'; | |
console.log(scope, local, global); | |
}; | |
x() //=>lalala local global undefined を返す。 | |
(function (){console.log(local);})(); //関数の即時実行形式。ReferenceError: local is not definedになる。 | |
(function (){console.log(global);})(); //=>global undefined |
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
var global = "global"; | |
(function x(){ //即時実行形式なのでカッコ()が多いです。 | |
console.log(global); //=>undefined ローカル変数globalが定義されているが(var global;)、中身がない状態。 | |
var global = "local"; //文字列localが代入された。 | |
console.log(global); //=>local ローカル変数globalの中身がそのまま出力される。 | |
})(); |
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
(function x(){ | |
var local = "local"; | |
if(true){ | |
console.log(local); //=>local | |
var block_scope = "block_scope"; | |
}; | |
console.log(block_scope); //=>block_scope が出力される。上のifブロックで定義した変数block_scopeの中身が出力されている。 | |
})(); | |
console.log(block_scope); //=>ReferenceError: block_scope is not defined 当たり前ですが、上の関数内で定義されたローカル変数は関数内でしか参照できません。 |
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
(function x(){ | |
var local = "local"; | |
if(true){ | |
console.log(local); //=>local | |
let block_scope = "block_scope"; //変数定義にletを使うと、定義したブロック内でのみ参照できるようになる。 | |
console.log(block_scope); //=>block_scope | |
} | |
console.log(block_scope); //=>block_scope is not defined エラーになる。 | |
})(); |
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
function counter(){ | |
var i = 0; //ローカル変数iを定義する。counter関数内のみ参照できる。 | |
return function(){ //無名関数を返す。 | |
return ++i; //iに1を足した結果を返す処理。 | |
} | |
} | |
var x = counter(); //変数xに関数counterの実行結果を代入する。関数counterは実行するとローカル変数iを定義し、無名関数を返す。よって変数xには「ローカル変数iに、1を足した結果を返す処理を持つ無名関数」が代入される。 | |
x(); //=>1 無名関数を実行する。ローカル変数iに、1を足した結果が返る。 |
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
var pi = { //変数piにオブジェクトを代入する。jsのオブジェクトはプロパティの集合である。 | |
name: "pipipi" | |
} | |
var hi = function(name){ //オブジェクトを受け取って、そのオブジェクトのnameプロパティを表示する無名関数を変数を | |
console.log( "name is"+ this.name ); | |
} | |
hi.call(pi); //本来piオブジェクトが持っていないhiメソッドを適用する。 |
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
var avg = function(){ //仮引数を定義しない。平均を求める関数は、任意の数の引数を受け取るのが望ましい。 | |
var total = 0; | |
for(var i=0; i<arguments.length; i++){ //もし、呼び出すときに引数を入れなくても問題なく動く。 | |
total += arguments[i]; | |
} | |
return total/arguments.length; | |
} | |
console.log(avg(2,4);); //=>3 | |
console.log(avg([2,4]);); //=>NaN Not A Numberの略。実引数は配列を想定していない。 |
OlderNewer