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
let count = 0 | |
let memo = [1, 1] | |
main() | |
function main () { | |
let a = [] | |
for (let i = 0; i < 20; i++) { | |
a.push(fibonacci(i)) | |
} | |
console.log('count ', count) |
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
main() | |
function main () { | |
// let arr = [5, 8, 4, 2, 6, 1, 3, 9] | |
let arr = [6, 4, 1, 7, 3, 9, 8] | |
printArray(arr) | |
straightInsertionSort(arr, arr.length) | |
printArray(arr) |
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
main() | |
function main () { | |
let a = [] | |
for (let i = 0; i < 20; i++) { | |
a.push(fibonacci(i)) | |
} | |
console.log(a.join(' ')) | |
} |
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
main() | |
function main () { | |
let a = [5, 7, 15, 28, 29, 31, 39, 58, 68, 70, 95] | |
const key = 39 | |
const index = binarySearch(a, a.length - 1, key) | |
console.log('index ', index) | |
} | |
function binarySearch (a, n, key) { |
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
main() | |
function main () { | |
let arr = [5, 8, 4, 2, 6, 1, 3, 9] | |
printArray(arr) | |
straightSelectionSort(arr, arr.length) | |
printArray(arr) | |
} | |
function straightSelectionSort (a, n) { |
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
main() | |
function main () { | |
let arr = [5, 8, 4, 2, 6, 1, 3, 9] | |
printArray(arr) | |
bubleSort(arr, arr.length) | |
printArray(arr) | |
} | |
function swap (a, idx1, idx2) { |
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
main() | |
function main () { | |
let arr = [5, 8, 4, 2, 6, 1, 3, 9] | |
console.log('original: ') | |
printArray(arr) | |
quickSort(arr, 0, arr.length - 1) | |
} | |
function swap (a, idx1, idx2) { |
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
async function main () { | |
const user = await getUser('kodai', 'nakamura') | |
const email = await getEmail(user) | |
return email | |
} | |
main() | |
.then(email => { | |
console.log(email) | |
}) |
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
// JavaScript O'reilly | |
// スコープチェーン | |
// 関数が定義されたときに、現在有効なスコープチェーンを保存しておく。 | |
// 関数が呼び出されたときに、新たにオブジェクトを生成し、ローカル変数を保存。 | |
// 新たに生成されたオブジェクトをスコープチェーンに追加し、新たなスコープチェーンを生成。 | |
// 入れ子の場合は、外側の関数が呼び出されるたびに内側の関数が再び定義される。 | |
// そのため、外側の関数の呼び出しごとに、スコープチェーンがことなる。 | |
var scope = '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
var scope = "global" | |
function fn () { | |
console.log(scope) | |
var scope = "local" | |
console.log(scope) | |
} | |
function fn2 () { | |
console.log(scope) |