Skip to content

Instantly share code, notes, and snippets.

@kenmori
Last active October 12, 2025 19:14
Show Gist options
  • Save kenmori/1961ce0140dc3307a0e641c8dde6701d to your computer and use it in GitHub Desktop.
Save kenmori/1961ce0140dc3307a0e641c8dde6701d to your computer and use it in GitHub Desktop.

Revisions

  1. kenmori revised this gist Sep 27, 2024. 1 changed file with 60 additions and 16 deletions.
    76 changes: 60 additions & 16 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@
    **更新情報**

    ```txt
    ・constをletに修正、問題を追加(2024/9/27)
    ・問題を追加(2024/7/20)
    ・問題を追加(2024/4/12)
    ・リファクタリング(2023/4/22)
    @@ -227,7 +228,7 @@ array.join("");
    const array = ['a', 'b', 'c'];
    let str = '';
    const count = array.length;
    for(const i= 0; i < count; i++){
    for(let i= 0; i < count; i++){
    str += array[i];
    }
    str
    @@ -2482,14 +2483,14 @@ div要素を10個作ってidがparentの子要素として追加してくださ
    ```js
    //bad
    const parent = document.getElementById('parent');
    for(const i = 0; i < 10; i++){
    for(let i = 0; i < 10; i++){
    const child = document.createElement('div');
    parent.appendChild(child);;
    }

    //good
    const fragment = document.createDocumentFragment();
    for(const i = 0; i < 10; i++){
    for(let i = 0; i < 10; i++){
    const child = document.createElement('div');
    fragment.appendChild(child);
    }
    @@ -5407,7 +5408,7 @@ if (color in colorObj) {

    function toObject(arry){
    const obj = {};
    for(const i = 0; i < arry.length; i++){
    for(let i = 0; i < arry.length; i++){
    obj[i] = arry[i];
    }
    return obj
    @@ -5424,7 +5425,7 @@ toObject(arry);
    ```js
    let html = '';
    const count = 10;
    for(const i = 0;i < count; i++){
    for(let i = 0;i < count; i++){
    html += 'hai!!';
    }
    document.querySelector('#mngb').innerHtml = html;
    @@ -5436,7 +5437,7 @@ document.querySelector('#mngb').innerHtml = html;
    ```js
    const html = [];
    const count = 10;
    for(const i = 0; i < count; i++){
    for(let i = 0; i < count; i++){
    html.push('hei!!');
    }
    document.querySelector('#mngb').innerHtml = html.join('');
    @@ -6268,7 +6269,7 @@ const obj = {
    ```js

    const foo = document.getElementById('foo');
    for(const i = 0; i < foo.classList.length; i++) {
    for(let i = 0; i < foo.classList.length; i++) {
    console.log(foo.classList[i]);
    }

    @@ -6971,7 +6972,7 @@ coを使って、1から始まり1秒ごとにインクルメントされた値
    };
    const num = co.wrap(function* (num){
    for(const i = 1; i <= num; i++) {
    for(let i = 1; i <= num; i++) {
    yield sleep(i);
    console.log(i)
    }
    @@ -9042,7 +9043,7 @@ let high = temp.findLast((t) => t > 40);
    // ES2023
    ```
    **問題388**
    **問題389**
    こちらの気温リストの中で41度以上のインデックスを取得してください。
    @@ -9059,7 +9060,7 @@ let index = temp.findLastIndex((t) => t > 40);
    // ES2023
    ```
    **問題389**
    **問題390**
    こちらの配列
    @@ -9077,7 +9078,7 @@ newMonths // ["Januar", "Februar", "March", "April"];
    // ES2023
    ```
    **問題390**
    **問題391**
    こちらの配列
    @@ -9097,7 +9098,29 @@ spliced // ["Feb", "Mar", "Apr"]
    > ES2023では、元の配列を変更せずに配列を分割する安全な方法として、Array toSpliced()メソッドが追加されました。 新しいtoSpliced()メソッドと古いsplice()メソッドの違いは、新しいメソッドは元の配列を変更せずに新しい配列を作成するのに対し、古いメソッドは元の配列を変更する点です。
    **問題391**
    **問題392**
    こちらの配列
    ```js
    const nums = [1, 4, 3, 2];
    ```
    の要素である数値を順番通りにする配列newNumsを作ってください。
    `[1,2,3,4]`
    尚、元の配列numsは破壊してはいけません。
    ```js
    const newNums = nums.toSorted();


    // ES2023
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted
    ```
    **問題393**
    `[1, 2, 3]``[1,2,4]`があります。どちらにも含まれている値をSetで取得してください。
    @@ -9108,7 +9131,7 @@ set // Set{1, 2}
    Set.intersectionは要素と引数のうちどちらにも含まれるものを返します(AND)
    **問題392**
    **問題394**
    `[1, 2]``[1, 3]`があります。要素と引数のうち少なくともどちらか片方に含まれるものをSet型で返してください
    @@ -9119,7 +9142,7 @@ set // Set{1, 2, 3}
    > Set.union 要素と引数のうち少なくともどちらか片方に含まれるものを返す OR
    **問題393**
    **問題395**
    `[1, 2]``[1, 3]`があります。要素の中で引数に含まれないものをSet型で返してください
    @@ -9130,7 +9153,7 @@ set // Set{2}
    > Set.difference 要素の中で引数に含まれないものを返す 差集合
    **問題394**
    **問題396**
    `[1, 2]``[1, 3]`があります。要素と引数どちらか一方にしか含まれないものをSet値で返してください
    @@ -9143,6 +9166,26 @@ set // Set{2, 3}
    > Set.symmetricDifference 要素と引数どちらか一方にしか含まれないものを返す XOR
    **問題397**
    次の配列
    ```js
    let array = [1, 2, 3, 4, 5]
    ```
    を数値`n`を与えたらindexが`n分`右に移動する関数を書いてください
    例えば`n=2`だとすると結果は
    ```js
    [4, 5, 1, 2, 3]
    ```
    になります
    ---
    [付録] 便利かもしれないユーティリティ関数
    @@ -9239,4 +9282,5 @@ console.log(hasOwnDeepProperty(obj, 'another')); // false
    <https://www.sitepoint.com/javascript-decorators-what-they-are/>
    <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set>
    <https://tc39.es/proposal-set-methods/#sec-set.prototype.intersection>
    </details>
    <https://stackoverflow.com/questions/47947697/for-which-use-cases-does-array-prototype-copywithin-exist>
    </details>
  2. kenmori revised this gist Jul 20, 2024. No changes.
  3. kenmori revised this gist Jul 20, 2024. 1 changed file with 537 additions and 281 deletions.
    818 changes: 537 additions & 281 deletions JavaScript.md
    537 additions, 281 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
  4. kenmori revised this gist Apr 12, 2024. 1 changed file with 107 additions and 169 deletions.
    276 changes: 107 additions & 169 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -4,23 +4,16 @@

    **更新情報**

    ```
    ```txt
    ・問題を追加(2024/4/12)
    ・リファクタリング(2023/4/22)
    ・Decoratorsに関する問題を追加(2020/6/6)
    ・リンクを追加(2020/5/30)
    ・問題を追加(2020/4/18)
    ・表記揺れを整理(2020/1/13)
    ・TypeScript問題集のリンク追加(2019/7/13)
    ・問題を追加(2019/4/30) 平成最終日
    ・問題を追加(2019/4/16)
    ・問題を追加(2018/11/26)
    ・問題9の誤字を修正(2018/5/22)
    ```


    こちらは[よしもと芸人もりたけんじ](https://profile.yoshimoto.co.jp/talent/detail?id=3871)が自身のテストとして作ったJavaScript練習問題集です。([TypeScript練習問題はこちら](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662))

    [![Twitter URL](https://twitter.com/terrace_tech)](https://twitter.com/terrace_tech)
    [X](https://twitter.com/terrace_tech)

    **前提**

    @@ -30,23 +23,19 @@

    ※答えはあくまで1つの記述です。

    ※ECMAScript2015の観点からは非奨励な書き方も載せています。(varやfor-in、破壊的メソッドの使用など)
    環境に因って使用せざるを得ないなどがその理由です。(また、varの場合、コンソールログ上でそのままコピペ、再定義されているエラーを出させないというのもあります)
    ※ECMAScript2015の観点からは非奨励な書き方も載せています。(varやfor-in、破壊的メソッドの使用など)
    環境に因って使用せざるを得ないなどがその理由です。
    また以下に示す問題の答えがあなたの考えた答えより冗長な書き方かもしれません。
    適宜置き換えていただけたらと思います。
    「答え」より端的な書き方、違うメソッド使用で解決できるなら「それが答え」です。

    ・途中似ているような問題が出てくるかもしれませんが気にしないでください。

    ・答えが見えてしまっているのは都度操作させないためです。

    ※・プルリク歓迎です。修正依頼は[こちら](https://omajimedesign.drift.com/omajimedesign)

    ※・プルリク歓迎です。修正依頼は[こちら](https://twitter.com/terrace_tech)のDMからお願いします。
    *★を押していただけたら今後もやる気出ます。よろしくお願いします。

    [blog/JavaScript](https://kenjimorita.jp/category/javascript/)

    [Twitter](https://twitter.com/bukostunikki)
    [X](https://twitter.com/bukotsunikki)

    [GitHub](https://github.com/kenmori)

    @@ -235,7 +224,7 @@ array.join("");
    const array = ['a', 'b', 'c'];
    let str = '';
    const count = array.length;
    for(const i= 0; i < count; i++){
    for(let i= 0; i < count; i++){
    str += array[i];
    }
    str
    @@ -254,11 +243,11 @@ let y = 3
    ```js
    deleteは暗黙に定義された場合は変数は削除できるが、
    const(let) や function文中の変数はnon-configurableであり削除できない
    var(let) や function文中の変数はnon-configurableであり削除できない

    //globaleオブジェクト
    x = 43;
    delete x
    delete x
    //true //暗黙に定義されたglobale変数なので

    //var宣言
    @@ -604,8 +593,8 @@ add(1,2) //3
    クロージャーを使ったファクトリー関数。
    ```js
    const fafa = Factory('morita');
    fafa.introduce()
    const f = Factory('morita');
    f.introduce()
    //'morita'
    ```
    上記のような実行をしたら渡したname(ここではmorita)が表示されるメソッドintroduceを持つファクトリー関数を定義しなさい。
    @@ -715,7 +704,7 @@ Object.getOwnPropertyDescriptor(obj, 'x');
    **問31**
    こちら
    ```const obj2 = {x : 2};```にObjectメソッドを用いてプロパティ```y```、値```2``````プロパティ追加可能```を定義して、Objectメソッドで情報(値と属性)を返してくださいP149
    ```let obj2 = {x : 2};```にObjectメソッドを用いてプロパティ```y```、値```2``````プロパティ追加可能```を定義して、Objectメソッドで情報(値と属性)を返してくださいP149
    ```js
    let obj2 = {x : 2};
    @@ -901,7 +890,7 @@ arguments オブジェクトへの値の割り当ての禁止
    'use strict';
    //8進数リテラルを使用するとsyntaxError
    //標準モードで実行する場合はあoctに数値8が割り当てられる。
    const oct = 010;
    let oct = 010;

    - Functionオブジェクトのcallerプロパティのアクセス禁止

    @@ -975,18 +964,18 @@ const nodelist = [...document.querySelectorAll('div')];
    ```
    **問39**
    配列```const arr = ['f','o','x','k'];```をインデックス順に出力させてください
    配列```let arr = ['f','o','x','k'];```をインデックス順に出力させてください
    ```js
    const arr = ['f','o','x','k'];
    let arr = ['f','o','x','k'];
    for(let j of arr){
    console.log(j)
    }


    //別解

    const arr = ['f','o','x','k'];
    let arr = ['f','o','x','k'];
    arr.forEach(function(ele){
    console.log(ele);
    }
    @@ -1012,18 +1001,19 @@ eArr.next().value //k
    ```js
    letarry = ['a', 'b', 'c', 'd', 'e'];
    let arry = ['a', 'b', 'c', 'd', 'e'];
    arry.splice(2, 0 , 'morita');
    arry
    //['a', 'b','morita', 'c', 'd', 'e']
    ```
    **問42**
    これ```const o = {};```と同じ意味を持つコードをObjectのAPIを使って生成してください
    これ```let o = {};```と同じ意味を持つコードをObjectのAPIを使って生成してください
    ```js
    const o = Object.create(Object.prototype);
    let o = Object.create(Object.prototype);
    ```
    **問43**
    @@ -1471,7 +1461,7 @@ console.log('repeat'.repeat(2));
    文字列```foo```をイテレーターを使い```['f','o','o']```となるようにしてください。
    ```js
    const chars = [];
    let chars = [];
    for (let n of 'foo'){
    chars.push(n);
    }
    @@ -1599,7 +1589,7 @@ const obj = {foo, bar};
    下のように
    ```
    const key = 'foo';
    const obj = {};
    let obj = {};
    obj[key] = 0;
    obj[key + '_bar'] = 1;
    ```
    @@ -1790,9 +1780,9 @@ result//['kenjisan', 'moritasan']
    ```js
    const aa = [{name: 'kenji'},{name: 'morita'}];
    const arry = [];
    let arry = [];
    aa.forEach(function(ele, i){
    for (const key in ele){
    for (let key in ele){
    arry.push(ele[key] + 'san')
    }
    });
    @@ -1964,16 +1954,16 @@ aaをbbにシャローコピーしてbb[0]に任意の文字列を代入し、aa
    ```js
    //concat
    const aa = ['oo', 'll'];
    const arry = [];
    let aa = ['oo', 'll'];
    let arry = [];
    const bb = arry.concat(aa);//shallow copy
    bb[0] = 'kk';
    aa//['oo', 'll']
    bb//['kk', 'll']

    //slice
    const aa = ['oo', 'll'];
    const bb = aa.slice(0, aa.length);
    let bb = aa.slice(0, aa.length);
    bb[0] = 'kk';
    aa//['oo', 'll']
    bb//['kk', 'll']
    @@ -2037,13 +2027,13 @@ arraytext
    'ab,cde,fgh,ijkl'
    ```js
    const text = 'abc def ghi jkl';
    let text = 'abc def ghi jkl';
    text.replace(/(.)\s/g,',$1');
    'ab,cde,fgh,ijkl'

    //or

    const text = 'abc def ghi jkl';
    let text = 'abc def ghi jkl';
    text.replace(/(.)\s/g,function(m0, m1){
    return ',' + m1
    });
    @@ -2246,15 +2236,15 @@ value
    配列arrayが空ならfalseが返るようにしてください
    ```js
    const array = [];
    let array = [];
    array.length !== 0
    //false
    ```
    **問108**
    こちらは自身のプロパティが定義されていない場合falseが返ることを期待しているがtrueが返る
    ```js
    const obj = {};
    let obj = {};
    obj ? true : false;
    ```
    自身のプロパティを持っていない場合falseが返るようにしてください
    @@ -2402,7 +2392,7 @@ gen.next().valueを実行すると値が1づつ返ってくるようなGenerator
    ```js
    function* idMaker(){
    const index = 0;
    let index = 0;
    while(true)
    yield index++;
    }
    @@ -2476,14 +2466,14 @@ div要素を10個作ってidがparentの子要素として追加してくださ
    ```js
    //bad
    const parent = document.getElementById('parent');
    for(const i = 0; i < 10; i++){
    for(let i = 0; i < 10; i++){
    const child = document.createElement('div');
    parent.appendChild(child);;
    }

    //good
    const fragment = document.createDocumentFragment();
    for(const i = 0; i < 10; i++){
    for(let i = 0; i < 10; i++){
    const child = document.createElement('div');
    fragment.appendChild(child);
    }
    @@ -2914,11 +2904,11 @@ numObj.toFixed();
    こちらの
    ```js
    const thing = 'global';
    var thing = 'global';
    function foo(){
    console.log(thing);
    if(true){
    const thing = 'local';
    var thing = 'local';
    console.log(thing);
    }
    }
    @@ -2927,11 +2917,11 @@ foo();
    のconsole.logはそれぞれ何を出力するか答えなさい。またそうなる理由を説明してください
    ```js
    const thing = 'global';
    var thing = 'global';
    function foo(){
    console.log(thing);
    if(true){
    const thing = 'local';
    var thing = 'local';
    console.log(thing);
    }
    }
    @@ -2940,9 +2930,9 @@ foo();
    //local

    //この記述をすると関数内宣言内での変数宣言は巻き上げられてjavascriptは下のように解釈をするから
    const thing = 'global';
    var thing = 'global';
    function foo(){
    const thing;//巻き上げ
    var thing;//巻き上げ
    console.log(thing);
    if(true){
    thing = 'local';
    @@ -3096,16 +3086,16 @@ objA.add(2,5);
    このような
    ```js
    const array = ['shibuya','shinjuku','ebisu','shinagawa','tokyo','ueno','ikebukuro'];
    let array = ['shibuya','shinjuku','ebisu','shinagawa','tokyo','ueno','ikebukuro'];
    ```
    配列がある。
    変数aに'shinjuku'、bに'ikebukuro'が代入されるように簡潔に記述してください
    ```js
    const array = ['shibuya','shinjuku','ebisu','shinagawa','tokyo','ueno','ikebukuro'];
    const [,a,,,,, b] = array;
    let array = ['shibuya','shinjuku','ebisu','shinagawa','tokyo','ueno','ikebukuro'];
    let [,a,,,,, b] = array;
    a
    //"shinjuku"
    b
    @@ -3393,7 +3383,7 @@ arry
    ```js
    const string = "apple banana orenge";
    const arrayed = string.split(" ");
    const obj ={};
    let obj ={};
    arrayed.forEach(function(elem,i){
    obj[i] = elem;
    });
    @@ -3405,7 +3395,7 @@ obj
    const string = "apple banana orenge";
    const arrayed = string.split(" ");
    const map = new Map();
    const obj ={};
    let obj ={};
    arrayed.forEach(function(elem,i){
    map.set(i,elem);
    })
    @@ -3415,7 +3405,7 @@ map
    //entries
    const string = "apple banana orenge";
    const arrayed = string.split(" ");
    const newarray =[];
    let newarray =[];
    for(value of arrayed.entries()){
    newarray.push(value)
    }
    @@ -3459,7 +3449,7 @@ condition && dosomething();
    こちらは
    ```
    for (const i=0; i<5; i++) {
    for (let i = 0; i < 5; i++) {
    setTimeout(function(){
    console.log(i);
    }, 1000 * (i+1));
    @@ -3474,7 +3464,7 @@ for (const i=0; i<5; i++) {
    その後タイムアウトが実行され、
    iの現在の値(5)が使用されます。

    for (const i=0; i<5; i++) {
    for (let i=0; i<5; i++) {
    const temp = i;
    setTimeout(function(){
    console.log(temp);
    @@ -3486,8 +3476,8 @@ for (const i=0; i<5; i++) {
    変数の初期化はスコープの先頭に吊り下げられるため、
    これも機能しません。
    実際、前のブロックは次のものと同じです
    const temp;
    for (const i=0; i<5; i++) {
    var temp;
    for (let i=0; i<5; i++) {
    temp = i;
    setTimeout(function(){
    console.log(temp);
    @@ -3499,7 +3489,7 @@ iをコピーする方法はいくつかあります。
    関数を宣言し、iを引数として渡すことによってクロージャを作成することです。
    ここでは、これを自己呼び出し関数として実行します。

    for (const i=0; i<5; i++) {
    for (let i=0; i<5; i++) {
    (function(num){
    setTimeout(function(){
    console.log(num);
    @@ -3813,7 +3803,7 @@ const people = [
    },
    age: 27
    }];
    for (const {name: n, family: {mother : f}} of people){
    for (let {name: n, family: {mother : f}} of people){
    console.log("Name " + n + ", Mother: " + f);
    }
    //Name ken, Mother: jone Smith
    @@ -4087,7 +4077,7 @@ console.log(key + 'のストレージは' + localStorage[key]);
    **問201**
    ローカルストレージの値を存在するだけ列挙してください
    ```js
    for (const i = 0; i < localStorage.length; i++){
    for (let i = 0; i < localStorage.length; i++){
    console.log(localStorage.key(i))
    }
    ```
    @@ -4269,7 +4259,7 @@ console.log(obj.prop); // 456
    ```js
    const locationsearch = '?id=12345&category=script&isname=true';
    const result = {};
    let result = {};
    locationsearch.substring(1).split("&").forEach(function(ele, i){
    const key = ele.split("=");
    result[key[0]] = decodeURIComponent(key[1]);
    @@ -4335,7 +4325,7 @@ flatArray
    ```js
    const arr = [];
    for (const i=0; i < 3; i++) {
    for (let i = 0; i < 3; i++) {
    arr.push(() => i);
    }
    arr.map(x => x()); // [3,3,3]
    @@ -4554,7 +4544,7 @@ function withLogging(wrappedFunction){
    return result;
    };
    }

    const addAndLog = withLogging(add);
    addAndLog(1, 2)
    //result 3
    @@ -4566,6 +4556,7 @@ multiplyAndLog(40,4)

    ```
    **問221**
    document内のh1を全て取得し、インデックス1番目のh1を削った残りを返してください
    @@ -4595,7 +4586,7 @@ a.search(/\d/) < b.search(/\d/);
    ```js
    const div = '<div>about me</div>';
    const divarray=[];
    let divarray=[];
    divarray.push(/\<div\>(.+)\<\/div\>/.exec(div)[1])
    divarray
    //['about me']
    @@ -4607,7 +4598,7 @@ divarray
    WIP
    ```js
    const i = 0;
    let i = 0;
    const array = [];
    do {
    array.push(Math.pow(2,i));
    @@ -4677,7 +4668,7 @@ ary
    **問229**
    こちらの変数を使って
    const ary = [0, 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10];
    cons ary = [0, 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10];
    2でも3でも割り切れない数を抽出した配列を生成してください
    ```js
    @@ -4768,7 +4759,7 @@ divの中にあるtextを全て出力してください
    ```js
    const s = 'aaa<div>bbb</div>ccc<div>ddd</div>eee';
    const divStringAry = [];
    let divStringAry = [];
    const regexp = /<div>.*?<\/div>/g;
    const result = regexp.exec(s);
    while(result != null){
    @@ -4793,8 +4784,8 @@ divStringAry.join('\n')
    ```js

    const ary = [];
    const i = 0;
    let ary = [];
    let i = 0;
    do {
    ary[i] = Math.pow(2, i);
    i += 1;
    @@ -4803,8 +4794,8 @@ ary
    //[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]

    //別解
    const ary = [];
    for(const n = 0; n <= 10; n++){
    let ary = [];
    for(let n = 0; n <= 10; n++){
    ary[n] = Math.pow(2, n);
    }
    ```
    @@ -4815,9 +4806,9 @@ for(const n = 0; n <= 10; n++){
    今年の各月の最終日を配列に格納してくださいl。インデックスは各月と一致する数値とする。
    ```js
    const ary = [];
    let ary = [];
    const temp = new Date();
    for (const i = 1; i <= 12; i++){
    for (let i = 1; i <= 12; i++){
    const d = 28;
    temp.setMonth(i - 1, d);
    while(temp.getMonth() == i - 1){//次の月になるまでroop
    @@ -5029,7 +5020,7 @@ o && o.f && o.f();


    **246**
    ```const v```の値を確実に数値にしたい。
    ```const ```の値を確実に数値にしたい。
    'a'が入ってきた場合NaNではなく0を代入するようにしてください。

    ```js
    @@ -5097,8 +5088,8 @@ http://programmers.stackexchange.com/questions/285881/any-point-in-using-es6-map
    http://stackoverflow.com/questions/18541940/map-vs-object-in-javascript
    Object:
    const o = {};
    const o = Object.create(null);
    let o = {};
    let o = Object.create(null);
    o.key = 1;
    o.key += 10;
    for(let k in o) o[k]++;
    @@ -5132,10 +5123,10 @@ pop、push、reverse、shift、sort、splice、unshilft

    **251**

    ```const arr = ['one', 'two', 'three']```においてarrを不変オブジェクトに変更してください。
    ```let arr = ['one', 'two', 'three']```においてarrを不変オブジェクトに変更してください。

    ```js
    const arr = ['one', 'two', 'three']
    let arr = ['one', 'two', 'three']
    Object.freeze(arr);
    arr.sort();
    //Uncaught TypeError: Cannot assign to read only property '1' of object '[object Array]'
    @@ -5149,14 +5140,14 @@ console.log(obj)
    //ex2
    //「子供」までは面倒みない
    const obj2 = Object.freeze({a: 1, b : {a: 2}})
    let obj2 = Object.freeze({a: 1, b : {a: 2}})
    obj2.b.a = 4
    console.log(obj2.b.a);
    //4
    //ex3
    //子供も凍結させる
    const obj3 = Object.freeze({a: 1, b: Object.freeze({a: 2})})
    let obj3 = Object.freeze({a: 1, b: Object.freeze({a: 2})})
    obj3.b.a = 4
    console.log(obj3.b.a)
    //2
    @@ -5242,7 +5233,7 @@ e.g const obj = {add : function(){some}};
    const obj = { foo: 'bar', baz: 42 }; をMapオブジェクトに変換してください

    ```js
    const obj = { foo: 'bar', baz: 42 };
    const obj = { foo: 'bar', baz: 42 };
    const map = new Map(Object.entries(obj));
    console.log(map); // Map { foo: 'bar', baz: 42 }
    @@ -5366,8 +5357,8 @@ if (color in colorObj) {
    ```js

    function toObject(arry){
    const obj = {};
    for(const i = 0; i < arry.length; i++){
    let obj = {};
    for(let i = 0; i < arry.length; i++){
    obj[i] = arry[i];
    }
    return obj
    @@ -5384,7 +5375,7 @@ toObject(arry);
    ```js
    let html = '';
    const count = 10;
    for(const i = 0;i < count; i++){
    for(let i = 0; i < count; i++){
    html += 'hai!!';
    }
    document.querySelector('#mngb').innerHtml = html;
    @@ -5394,9 +5385,9 @@ document.querySelector('#mngb').innerHtml = html;
    をより高速な書き方をしてください
    ```js
    const html = [];
    let html = [];
    const count = 10;
    for(const i = 0; i < count; i++){
    for(let i = 0; i < count; i++){
    html.push('hei!!');
    }
    document.querySelector('#mngb').innerHtml = html.join('');
    @@ -5566,9 +5557,9 @@ sortedCharacters === characters
    ```js
    const generatorFunction = function* (){
    const i = 0;
    let i = 0;
    while (true) {
    yield i ++;
    yield i++;
    }
    }
    const iterator = generatorFunction();
    @@ -5711,7 +5702,7 @@ const curry = (method, ...args) => {
    const controller = (generator) => {
    const iterator = generator();
    const advancer = (response) => {
    const state;
    let state;
    state = iterator.next(response);
    if (!state.done) {
    state.value(advancer);
    @@ -5781,7 +5772,7 @@ const create = function(i){
    return `<img src='${i}.png'>`;
    }
    const arry = [];
    for(const i of ge(1,7)){
    for(let i of ge(1,7)){
    arry.push(create(i))
    }
    ```
    @@ -5791,12 +5782,12 @@ for(const i of ge(1,7)){
    for-ofに渡すと1~10までの数値を返すitarableなオブジェクトを自作してください。
    ```js
    const obj = {}; // イテラブルなオブジェクト
    let obj = {}; // イテラブルなオブジェクト
    obj[Symbol.iterator] = function(){//イテレータを返す関数を代入
    const iterator = {}; // イテレータ
    const num = 1;
    let iterator = {}; // イテレータ
    let num = 1;
    iterator.next = function(){//next実行してリザルトを返す関数を代入
    const iteratorResult = (num <= 10)
    let iteratorResult = (num <= 10)
    ? { value: num++, done: false }
    : { value: undefined, done: true };
    return iteratorResult; // イテレータリザルトを返す
    @@ -5847,11 +5838,11 @@ iterator.next(1).value
    ```js
    function* foo(x) {
    const y = 2 * (yield (x + 1));
    const z = yield (y / 3);
    let y = 2 * (yield (x + 1));
    let z = yield (y / 3);
    return (x + y + z);
    }
    const it = foo(5);
    let it = foo(5);
    it.next();//1
    it.next(12);//2
    it.next(13);//3
    @@ -5861,11 +5852,11 @@ it.next(13);//3
    ```js
    function* foo(x) {
    const y = 2 * (yield (x + 1));
    const z = yield (y / 3);//2回目で返すのはyield式の結果までで結果はzに代入されない//3回目のnext引数がzに入る
    let y = 2 * (yield (x + 1));
    let z = yield (y / 3);//2回目で返すのはyield式の結果までで結果はzに代入されない//3回目のnext引数がzに入る
    return (x + y + z);
    }
    const it = foo(5);
    let it = foo(5);

    it.next();
    //{value: 6, done: false}
    @@ -6082,7 +6073,7 @@ obj["a"]
    //undefinedになります。実行時objの型が適切か気づくことができます。

    e.g
    const obj = 1;//オブジェクトが入ってくる想定のobjにプリミティブ型を代入
    let obj = 1;//オブジェクトが入ってくる想定のobjにプリミティブ型を代入
    Reflect.get(obj, 1)
    //Uncaught TypeError: Reflect.get called on non-object

    @@ -6165,7 +6156,7 @@ const handler = {
    }
    }

    const p = new Proxy({}, handler);
    let p = new Proxy({}, handler);
    p.a = 1
    p.a
    //1
    @@ -6231,7 +6222,7 @@ const obj = {
    ```js

    const foo = document.getElementById('foo');
    for(const i = 0; i < foo.classList.length; i++) {
    for(let i = 0; i < foo.classList.length; i++) {
    console.log(foo.classList[i]);
    }

    @@ -6528,7 +6519,7 @@ $.parseHTML(htmlString);
    ```js
    const parseHTML = function(str) {
    const tmp = document.implementation.createHTMLDocument();
    let tmp = document.implementation.createHTMLDocument();
    tmp.body.innerHTML = str;
    return tmp.body.children;
    };
    @@ -6786,7 +6777,7 @@ function f (name, time){
    });
    return done
    };
    const i = Promise.all([f('morita', 500),f('kkk', 500),f('jji', 500)])
    let i = Promise.all([f('morita', 500),f('kkk', 500),f('jji', 500)])
    i.then(()=> console.log("done"))
    ```
    @@ -6935,7 +6926,7 @@ coを使って、1から始まり1秒ごとにインクルメントされた値
    };
    const num = co.wrap(function* (num){
    for(const i = 1; i <= num; i++) {
    for(let i = 1; i <= num; i++) {
    yield sleep(i);
    console.log(i)
    }
    @@ -7097,7 +7088,7 @@ document.addEventListener('DOMContentLoaded', function() {
    こちらの実装は配列のインデックスを3000ms後に出力することを期待しています。
    ```js
    const arr = [10, 12, 15, 21];
    for (const i = 0; i < arr.length; i++) {
    for (let i = 0; i < arr.length; i++) {
    setTimeout(function() {
    console.log('The index of this number is: ' + i);
    }, 3000);
    @@ -7124,7 +7115,7 @@ for (const i = 0; i < arr.length; i++) {

    //変数iをそれぞれのfunctionに渡す
    const arr = [10, 12, 15, 21];
    for (const i = 0; i < arr.length; i++) {
    for (let i = 0; i < arr.length; i++) {
    // pass in the variable i so that each function
    // has access to the correct index
    setTimeout(function(i_local) {
    @@ -7638,9 +7629,9 @@ Stringオブジェクト上に整数値を受け取ってその数だけrepeat
    ```js
    String.prototype.repeatify = String.prototype.repeatify || function(times) {
    const str = '';
    let str = '';

    for (const i = 0; i < times; i++) {
    for (let i = 0; i < times; i++) {
    str += this;
    }

    @@ -7760,7 +7751,7 @@ logStuff({name: 'morita', job: engineer}, log);
    objはlogStuffの中でString型かObject型かチェックしてください。
    ```js
    const arr = [];
    let arr = [];
    function log(obj){
    if (typeof obj === 'string'){
    console.log(obj);
    @@ -7981,7 +7972,7 @@ f.hasOwnProperty('name') //自身にnameをもつ //2


    //Array
    const arry = [];
    let arry = [];
    arry.__proto__ === Array.prototype
    //true
    arry.__proto__ === [].__proto__
    @@ -8897,52 +8888,6 @@ console.log(generateNumber(4)) // [342, 920, 888, 292,129] or some

    ```
    **WIP**
    //問題文をわかりやすくする
    fun()を実行し、もしキャッシュがあればその値を返し、もしキャッシュがなければその引数をキャッシュのkeyとして値を返す関数を実装してください。
    ```js
    function fn() {
    console.log('Generate cache');
    const cache = {};
    return function(a) {
    let res = cache[a];
    if (res) {
    console.log('From cache');
    return res;
    } else {
    console.log('Calculate and save to cache');
    res = 'value' + a;
    cache[a] = res;
    return res;
    }
    };
    }
    const fun = fn()
    //Generate cache
    fun(1)
    //Calculate and save to cache
    //1
    fun(1)
    //From cache
    //1
    ```
    ```js

    //下記の関数

    function f(images, index, attributes){
    return {images: [ ...images.slice(0, index), {...images[index], ...attributes}, ...images.slice(index + 1)]}
    }
    f(["eeee","ppp","lll"], 1, [1,2,3])
    実行時出力結果を答えてください


    //images:[ "eeee", {0: 1, 1: 2, 2: 3} ,"lll"]
    ```
    [付録] 便利かもしれないユーティリティ関数
    @@ -8994,13 +8939,6 @@ console.log(hasOwnDeepProperty(obj, 'another')); // false
    [付録] [Observable](https://tc39.github.io/proposal-observable/)
    ```js


    ```
    </details>
  5. kenmori revised this gist Apr 12, 2024. 1 changed file with 435 additions and 417 deletions.
    852 changes: 435 additions & 417 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@
    **更新情報**

    ```
    ・リファクタリング(2023/4/22)
    ・Decoratorsに関する問題を追加(2020/6/6)
    ・リンクを追加(2020/5/30)
    ・問題を追加(2020/4/18)
    @@ -17,9 +18,9 @@
    ```


    こちらは[よしもと芸人もりたけんじ](https://kenjimorita.jp/aboutme/)が自身のテストとして作ったJavaScript練習問題集です。([TypeScript練習問題はこちら](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662))
    こちらは[よしもと芸人もりたけんじ](https://profile.yoshimoto.co.jp/talent/detail?id=3871)が自身のテストとして作ったJavaScript練習問題集です。([TypeScript練習問題はこちら](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662))

    [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/bukotsunikki.svg?style=social&label=Follow%20%40bukotsunikki)](https://twitter.com/bukotsunikki)
    [![Twitter URL](https://twitter.com/terrace_tech)](https://twitter.com/terrace_tech)

    **前提**

    @@ -234,7 +235,7 @@ array.join("");
    const array = ['a', 'b', 'c'];
    let str = '';
    const count = array.length;
    for(var i= 0; i < count; i++){
    for(const i= 0; i < count; i++){
    str += array[i];
    }
    str
    @@ -253,7 +254,7 @@ let y = 3
    ```js
    deleteは暗黙に定義された場合は変数は削除できるが、
    var(let) や function文中の変数はnon-configurableであり削除できない
    const(let) や function文中の変数はnon-configurableであり削除できない

    //globaleオブジェクト
    x = 43;
    @@ -266,7 +267,7 @@ false //削除できない

    //関数宣言文の中でのdelete
    function f(){
    var z = 44;
    const z = 44;
    delete z;
    console.log(z)
    }
    @@ -603,7 +604,7 @@ add(1,2) //3
    クロージャーを使ったファクトリー関数。
    ```js
    var fafa = Factory('morita');
    const fafa = Factory('morita');
    fafa.introduce()
    //'morita'
    ```
    @@ -714,7 +715,7 @@ Object.getOwnPropertyDescriptor(obj, 'x');
    **問31**
    こちら
    ```var obj2 = {x : 2};```にObjectメソッドを用いてプロパティ```y```、値```2``````プロパティ追加可能```を定義して、Objectメソッドで情報(値と属性)を返してくださいP149
    ```const obj2 = {x : 2};```にObjectメソッドを用いてプロパティ```y```、値```2``````プロパティ追加可能```を定義して、Objectメソッドで情報(値と属性)を返してくださいP149
    ```js
    let obj2 = {x : 2};
    @@ -766,7 +767,7 @@ arr.sort();
    **問34**
    ```var arr = [3,4,5];```をconcat以外で新たな配列として```arr2```にコピーしてください。その後```arr2[0]= 123```を代入するとarrは何を出力するか答えなさい
    ```let arr = [3,4,5];```をconcat以外で新たな配列として```arr2```にコピーしてください。その後```arr2[0]= 123```を代入するとarrは何を出力するか答えなさい
    ```js
    let arr = [3,4,5];
    @@ -830,7 +831,7 @@ strict modeの代表的な制約を挙げて説明してください。

    //オブジェクト生成時にエラー//標準モードで実行する場合は後に定義されたものが反映される

    var object = {
    const object = {
    prop1 : 100,
    prop1 : 200
    }
    @@ -900,7 +901,7 @@ arguments オブジェクトへの値の割り当ての禁止
    'use strict';
    //8進数リテラルを使用するとsyntaxError
    //標準モードで実行する場合はあoctに数値8が割り当てられる。
    var oct = 010;
    const oct = 010;

    - Functionオブジェクトのcallerプロパティのアクセス禁止

    @@ -974,18 +975,18 @@ const nodelist = [...document.querySelectorAll('div')];
    ```
    **問39**
    配列```var arr = ['f','o','x','k'];```をインデックス順に出力させてください
    配列```const arr = ['f','o','x','k'];```をインデックス順に出力させてください
    ```js
    var arr = ['f','o','x','k'];
    for(var j of arr){
    const arr = ['f','o','x','k'];
    for(let j of arr){
    console.log(j)
    }


    //別解

    var arr = ['f','o','x','k'];
    const arr = ['f','o','x','k'];
    arr.forEach(function(ele){
    console.log(ele);
    }
    @@ -996,8 +997,8 @@ arr.forEach(function(ele){
    またイテレーターを使い順番に出力してください
    ```js
    var arr = ['f', 'o', 'x', 'k'];
    var eArr = arr[Symbol.iterator]();
    const arr = ['f', 'o', 'x', 'k'];
    const eArr = arr[Symbol.iterator]();
    eArr.next().value //f
    eArr.next().value //o
    eArr.next().value //x
    @@ -1011,18 +1012,18 @@ eArr.next().value //k
    ```js
    var arry = ['a', 'b', 'c', 'd', 'e'];
    letarry = ['a', 'b', 'c', 'd', 'e'];
    arry.splice(2, 0 , 'morita');
    arry
    //['a', 'b','morita', 'c', 'd', 'e']
    ```
    **問42**
    これ```var o = {};```と同じ意味を持つコードをObjectのAPIを使って生成してください
    これ```const o = {};```と同じ意味を持つコードをObjectのAPIを使って生成してください
    ```js
    var o = Object.create(Object.prototype);
    const o = Object.create(Object.prototype);
    ```
    **問43**
    @@ -1037,10 +1038,10 @@ o = Object.create({}, {p: {value : 42}});
    1234という数字を文字列に変更後、配列の要素としてインデックス順に格納してください
    ```js
    var count = 1234;
    var ee = count.toString();
    var arr = [];
    for(var i = 0; i < ee.length; i++){
    const count = 1234;
    const ee = count.toString();
    let arr = [];
    for(let i = 0; i < ee.length; i++){
    arr[i] = ee.charAt(i);
    }
    console.log(arr)//['1','2','3','4'];
    @@ -1076,7 +1077,7 @@ console.log(arr)//['1','2','3','4'];

    //use for
    const a = [0, 1, 2, 3, 4];
    for (var i = 0; i < a.length; i++) {
    for (let i = 0; i < a.length; i++) {
    if (a[i] === 2) {
    break; // stop the loop
    }
    @@ -1088,9 +1089,9 @@ for (var i = 0; i < a.length; i++) {
    **問46**
    ```js
    var Speaker = {
    const Speaker = {
    say : function(wordsGetter){
    var words = wordsGetter();
    const words = wordsGetter();
    alert(words);
    }
    };
    @@ -1104,17 +1105,17 @@ Person.prototype.sayName = function(){
    return self.nickname;
    });
    };
    var person = new Person('moriken');
    const person = new Person('moriken');

    person.sayName();
    ```
    [答え2](http://jsbin.com/wacumupuqo/edit?js,console,output)
    ```js
    var Speaker = {
    const Speaker = {
    say : function(wordsGetter){
    var words = wordsGetter();
    const words = wordsGetter();
    alert(words);
    }
    };
    @@ -1127,7 +1128,7 @@ Person.prototype.sayName = function(){
    return this.nickname;
    }.bind(this));
    };
    var person = new Person('moriken');
    const person = new Person('moriken');

    person.sayName();
    ```
    @@ -1148,9 +1149,9 @@ array = [
    {name: 'kenji', mail:'[email protected]'},
    {name: 'morita', mail: '[email protected]'}
    ];
    var array2 = [];
    let array2 = [];
    array.forEach(function(Element, ind, array){
    for(var key in Element){
    for(let key in Element){
    if(key == 'mail'){

    array2.push(Element[key])
    @@ -1161,7 +1162,7 @@ console.log(array2);
    ```
    **問48**
    配列```var passed = [12, 5, 8, 130, 44]```の要素全てが10以上かどうかを評価してtrueかfalseを返してください。また10以上のものが一つでもあった場合trueを返してください。
    配列```let passed = [12, 5, 8, 130, 44]```の要素全てが10以上かどうかを評価してtrueかfalseを返してください。また10以上のものが一つでもあった場合trueを返してください。
    ```js
    function isBigEnough(ele, ind, arry){
    @@ -1212,9 +1213,9 @@ map.set('four', 'fafa@eee');
    //['three', 'hoso@fafa']
    ```js
    var fafa = [['one', 'info@fa'],['two', 'send@fafa'],['three', 'hoso@fafa']];
    var entries = map.entries();
    for (var entry of entries){
    const fafa = [['one', 'info@fa'],['two', 'send@fafa'],['three', 'hoso@fafa']];
    const entries = map.entries();
    for (const entry of entries){
    console.log(entry);
    }

    @@ -1323,7 +1324,7 @@ if (x) {
    //undefinedやnull以外のオブジェクトは実行されます

    //真偽値オブジェクトは格納されている値がfalseであってもtrueと評価される。
    var falseValue = new Boolean(false);
    const falseValue = new Boolean(false);
    console.log(falseValue)//false,真偽値オブジェクトが出力される
    if(falseValue){//真偽値オブジェクトの内容がfalseでもオブジェクト自体は常にtrue値をみなされる
    //run
    @@ -1388,12 +1389,12 @@ if (undefined == null){
    ```js
    const ii = function(){
    var pp = 'my ';
    const pp = 'my ';
    return function(value){
    console.log(pp + value);
    }
    }
    var kk = ii();
    const kk = ii();
    kk('home');
    //my home
    ```
    @@ -1432,7 +1433,7 @@ function getSomething(){
    third: 3
    }
    }
    var { first, second, third } = getSomething();
    const { first, second, third } = getSomething();
    first
    //1
    second
    @@ -1470,7 +1471,7 @@ console.log('repeat'.repeat(2));
    文字列```foo```をイテレーターを使い```['f','o','o']```となるようにしてください。
    ```js
    var chars = [];
    const chars = [];
    for (let n of 'foo'){
    chars.push(n);
    }
    @@ -1482,9 +1483,9 @@ console.log(chars);//['f','o','o']
    IteratableからIteratorを取得、要素を出力していきして「要素がもうない意」の```{value: undefined, done: true}```を出力してください
    ```js
    var arr = ['ooo', 'eee'];
    const arr = ['ooo', 'eee'];

    var Iterator = arr[Symbol.iterator]();
    const Iterator = arr[Symbol.iterator]();
    console.log(Iterator.next()); // { done: false, value: 'ooo'}
    console.log(Iterator.next()); // { done: false, value: 'eee' }
    console.log(Iterator.next()); //{ done: true, value: undefined }
    @@ -1496,7 +1497,7 @@ console.log(Iterator.next()); //{ done: true, value: undefined }
    ```js
    //スプレッドオペレータ
    var arr = [...'foo'];
    const arr = [...'foo'];
    console.log(arr);
    ```
    @@ -1506,7 +1507,7 @@ console.log(arr);
    ```js
    //分割代入
    var [index0, index1, ...rest] = 'morita';
    const [index0, index1, ...rest] = 'morita';
    console.log(index0,index1, rest);
    //'m'
    //'o'
    @@ -1535,8 +1536,8 @@ foo(1,2,3,4,5,6);
    ```js
    //スプレッドオペレータ

    var arr2 = [4, 5, 6];
    var arr = [1, 2, 3, ...arr2];
    const arr2 = [4, 5, 6];
    const arr = [1, 2, 3, ...arr2];
    console.log(arr);//[1, 2, 3, 4, 5, 6]
    ```
    @@ -1545,7 +1546,7 @@ console.log(arr);//[1, 2, 3, 4, 5, 6]
    下記のようなあるファイル(module.js)で記述した
    ```js
    var foo = 'foo';
    const foo = 'foo';
    function bar(){};
    class Baz{
    baz(){}
    @@ -1556,7 +1557,7 @@ class Baz{
    ```js
    //読み込まれる側
    var foo = 'foo';
    const foo = 'foo';
    function bar(){};
    class Baz{
    baz(){}
    @@ -1582,31 +1583,31 @@ import * as from './module';
    **問74**
    ```var obj = {foo: foo, bar: bar}```
    ```const obj = {foo: foo, bar: bar}```
    オブジェクトのkeyとvalueが等しい場合の記述
    をせよ
    ```js
    var obj = {foo: foo, bar: bar};
    var obj = {foo, bar};
    const obj = {foo: foo, bar: bar};
    const obj = {foo, bar};
    ```
    **問75**
    下のように
    ```
    var key = 'foo';
    var obj = {};
    const key = 'foo';
    const obj = {};
    obj[key] = 0;
    obj[key + '_bar'] = 1;
    ```
    書いていた記述をECMAScript2015の記述で書いてください
    ```js
    var key = 'foo';
    var obj = {
    const key = 'foo';
    const obj = {
    [key] : 0,
    [key + '_bar'] : 1
    }
    @@ -1659,14 +1660,14 @@ line2
    **問79**
    ```js
    var long = '30px';
    var weight = '40px';
    const long = '30px';
    const weight = '40px';

    function tag(strings, ...values){
    //console.log(strings);['身長','で、体重は','です']
    return `m:${values[0]}、p:${values[1]}`; };

    var str1 = tag`身長${long}で、体重は${weight}です`; console.log(str1);
    const str1 = tag`身長${long}で、体重は${weight}です`; console.log(str1);
    ```
    @@ -1683,7 +1684,7 @@ fun({a: 1, b: 4});//5
    **問81**
    ```var aa = [['morita', 'kenji', 'keiko'],['morita', 'kenji', 'keiko']```
    ```const aa = [['morita', 'kenji', 'keiko'],['morita', 'kenji', 'keiko']```
    全てのaaにある多次元配列の全ての要素に文字列'san'を付け加えて一つの配列として出力してください
    @@ -1704,16 +1705,16 @@ http://stackoverflow.com/questions/3034392/what-use-does-the-javascript-foreach-
    //map
    //新しいarrayを返す

    var a = [{ val: 1 }, { val: 2 }, { val: 3 }];
    var uu = a.map(function(el) {
    const a = [{ val: 1 }, { val: 2 }, { val: 3 }];
    const uu = a.map(function(el) {
    el.val++;
    return el.val
    });
    a//[{ val: 2 }, { val: 3 }, { val: 4 }]
    uu//[2, 3, 4]

    //forEach
    var a = [{ val: 1 }, { val: 2 }, { val: 3 }];
    const a = [{ val: 1 }, { val: 2 }, { val: 3 }];
    a.forEach(function(el) {
    el.val++;
    console.log(el.val);
    @@ -1727,16 +1728,16 @@ a.forEach(function(el) {

    //forEachが配列の要素を編集して配列で返すには
    //
    var a = [1,2,3],
    const a = [1,2,3],
    b = [];
    a.forEach(function(el) {
    b.push(el+1);
    });

    // b is now [2,3,4], a is unchanged [1, 2, 3]

    var a = [1, 2, 3];
    var b = a.map(function(elem){
    const a = [1, 2, 3];
    const b = a.map(function(elem){
    return elem + 1;
    });
    b// [2, 3, 4]
    @@ -1749,16 +1750,16 @@ cats.forEach(function(cat) {
    });


    var oo = [2,3,4,5,6];
    var aa = oo.map(function(x){
    const oo = [2,3,4,5,6];
    const aa = oo.map(function(x){
    return x + 1;
    });
    aa //[3, 4, 5, 6, 7]

    //forEach
    それぞれの配列の要素に対して何かしたいとき
    var oo = [2,3,4,5,6];
    var aa = oo.forEach(function(x){
    const oo = [2,3,4,5,6];
    const aa = oo.forEach(function(x){
    return x + 1;
    });
    aa// undefined
    @@ -1775,8 +1776,8 @@ aa// undefined
    ```js
    var aa = [{name: 'kenji'},{name: 'morita'}];
    var result = aa.map(function(ele, i){
    const aa = [{name: 'kenji'},{name: 'morita'}];
    const result = aa.map(function(ele, i){
    return ele.name + 'san';
    });
    result//['kenjisan', 'moritasan']
    @@ -1788,10 +1789,10 @@ result//['kenjisan', 'moritasan']
    問83と同じ事をforEachでしてください
    ```js
    var aa = [{name: 'kenji'},{name: 'morita'}];
    var arry = [];
    const aa = [{name: 'kenji'},{name: 'morita'}];
    const arry = [];
    aa.forEach(function(ele, i){
    for (var key in ele){
    for (const key in ele){
    arry.push(ele[key] + 'san')
    }
    });
    @@ -1854,7 +1855,7 @@ const obj = {
    下記のようなURLのファイルパスごとに配列に格納してください
    ```js
    var filepath = location.pathname.substring(1).split('/');
    const filepath = location.pathname.substring(1).split('/');
    filepath;

    //['kenmori', 'Angular2_TypeScript', 'tree', 'master', 'angular2-quickstart']
    @@ -1939,10 +1940,10 @@ function add ({name, id}){
    **問91**
    ```var aaa = [['oo','oo1'], ['ll','ll2']];```このような多次元配列のインデックス0番目だけを出力してください
    ```const aaa = [['oo','oo1'], ['ll','ll2']];```このような多次元配列のインデックス0番目だけを出力してください
    ```js
    var aaa = [['oo','oo1'], ['ll','ll2']];
    const aaa = [['oo','oo1'], ['ll','ll2']];
    aaa.forEach(function(ee){
    ee.filter(function(eee, i){
    if(i == 0){
    @@ -1957,92 +1958,92 @@ aaa.forEach(function(ee){
    Array destructuringとして簡潔に記述してください。
    シャローコピーとディープコピーの違いを教えてください。また
    ```var aa = ['oo', 'll'];```
    ```const aa = ['oo', 'll'];```
    aaをbbにシャローコピーしてbb[0]に任意の文字列を代入し、aa[0]の参照する値が変わらないことを確認してください
    ```js
    //concat
    var aa = ['oo', 'll'];
    var arry = [];
    var bb = arry.concat(aa);//shallow copy
    const aa = ['oo', 'll'];
    const arry = [];
    const bb = arry.concat(aa);//shallow copy
    bb[0] = 'kk';
    aa//['oo', 'll']
    bb//['kk', 'll']

    //slice
    var aa = ['oo', 'll'];
    var bb = aa.slice(0, aa.length);
    const aa = ['oo', 'll'];
    const bb = aa.slice(0, aa.length);
    bb[0] = 'kk';
    aa//['oo', 'll']
    bb//['kk', 'll']

    //bad
    //spliceは破壊的メソッド(元参照を変える)
    var aa = ['oo', 'll'];
    var bb = aa.splice(0, aa.length);
    const aa = ['oo', 'll'];
    const bb = aa.splice(0, aa.length);
    bb//['oo', 'll']
    aa//[]
    ```
    **問93**
    ```var aa = ['oo', 'll'];```をbbにコピーしてaaは['kk', 'jj'];が挿入されるようにしてください。期待する結果
    ```const aa = ['oo', 'll'];```をbbにコピーしてaaは['kk', 'jj'];が挿入されるようにしてください。期待する結果
    bb//['oo', 'll'];
    aa//['kk', 'jj'];
    ```js
    var aa = ['oo', 'll'];
    var bb = aa.splice(0, aa.length, ['kk','jj'])
    const aa = ['oo', 'll'];
    const bb = aa.splice(0, aa.length, ['kk','jj'])
    bb//['oo', 'll'];
    aa//['kk', 'jj'];
    ```
    **問94**
    このような配列
    ```var aa = ['ii', 'jj', 'kk'];```がある。'jj'要素を削除するために
    ```const aa = ['ii', 'jj', 'kk'];```がある。'jj'要素を削除するために
    deleteを使った場合とspliceを使った場合の違いは何か。それがわかるコードを書いてください
    ```js
    deleteは削除されたインデックスを残す。spliseは間を詰める。
    var aa = ['ii', 'jj', 'kk'];
    const aa = ['ii', 'jj', 'kk'];
    delete aa[1];
    aa//['ii', undefined, 'kk']
    var aa = ['ii', 'jj', 'kk'];
    const aa = ['ii', 'jj', 'kk'];
    aa.splice(1,1);
    aa//['ii', 'kk']
    ```
    **問95**
    ```var text = 'key and value';```このような文字列を単語毎に配列の要素として格納してください
    ```const text = 'key and value';```このような文字列を単語毎に配列の要素として格納してください
    //期待する結果
    //['key','and','value']
    ```js
    var text = 'key and value';
    var arraytext = ii.match(/\w+/g);
    const text = 'key and value';
    const arraytext = ii.match(/\w+/g);
    arraytext
    ['text', 'and', 'value']
    ```
    **問96**
    ```var text = 'abc def ghi jkl';```の空白の直前の文字をグループ化してカンマ文字の後ろに移動させなさい。
    ```const text = 'abc def ghi jkl';```の空白の直前の文字をグループ化してカンマ文字の後ろに移動させなさい。
    期待する文字列
    'ab,cde,fgh,ijkl'
    ```js
    var text = 'abc def ghi jkl';
    const text = 'abc def ghi jkl';
    text.replace(/(.)\s/g,',$1');
    'ab,cde,fgh,ijkl'

    //or

    var text = 'abc def ghi jkl';
    const text = 'abc def ghi jkl';
    text.replace(/(.)\s/g,function(m0, m1){
    return ',' + m1
    });
    @@ -2052,7 +2053,7 @@ text.replace(/(.)\s/g,function(m0, m1){
    **問97**
    ``` var array = ['aa','bb','cc','dd','ff'];```
    ``` const array = ['aa','bb','cc','dd','ff'];```
    このような配列の要素'bb'の前に'ff'を移動させて ``` ['aa','ff','bb','cc','dd'] ```このような配列を完成させてください
    ```js
    @@ -2115,7 +2116,7 @@ if(obj.a)が存在しても未定義だと実行されない
    **問100**
    ``` var arr = [ 10, 20 ]; ```においてarr[2]が存在しないことを確認してください
    ``` const arr = [ 10, 20 ]; ```においてarr[2]が存在しないことを確認してください
    ```js
    2 in arry;
    @@ -2126,7 +2127,7 @@ if(obj.a)が存在しても未定義だと実行されない
    **問101**
    ```var string = '-9';```を数値に変換してください
    ```const string = '-9';```を数値に変換してください
    ```js
    string - 0
    @@ -2143,33 +2144,33 @@ sliceとsubstringの違いを教えてください
    ```js
    //引数に-を与えた際に違いが出ます

    var str = 'あいうえお';
    const str = 'あいうえお';
    str.length
    str.slice(0,-2)
    //'あいう'
    //0からインデックス最後の文字を-1とし後ろから数える

    var str = 'あいうえお';
    const str = 'あいうえお';
    str.substring(0, -2);
    //'
    //負の数字は0とみなす。
    //0から0を取得するので空文字を返す

    //sliceは開始位置が終了位置以上だと空文字を返す

    var str = 'あいうえお';
    const str = 'あいうえお';
    str.slice(1,1)
    //'

    //「い」を取得したい場合
    var str = 'あいうえお';
    const str = 'あいうえお';
    str.slice(1,2)
    ''

    //substringの場合
    //開始位置が終了位置より大きいと交換されて解釈される

    var str = 'あいうえお';
    const str = 'あいうえお';
    str.substring(1,-3);
    //substring(-3,1)と解釈され負の数は0と見なされ
    //substring(0,1)と同等の処理をする
    @@ -2182,8 +2183,8 @@ str.substring(1,-3);
    次のような文字列```abcdefg```のcとeそれぞれを大文字にしてください
    ```js
    var str = 'abcdefg';
    var replaced = str.replace(/[ce]/g,function(str){
    const str = 'abcdefg';
    const replaced = str.replace(/[ce]/g,function(str){
    return str.toUpperCase();
    });
    //replaced 'abCdEfg'
    @@ -2192,7 +2193,7 @@ var replaced = str.replace(/[ce]/g,function(str){
    **問104**
    次のような文字列をvar str = 'こんにちは';
    var name = 'もりたさん';
    const name = 'もりたさん';
    連結し'いい天気ですね'を付け足した新しい文字列を生成してください
    期待する結果```'こんにちはもりたさんいい天気ですね'```
    @@ -2202,9 +2203,9 @@ str
    //こんにちは
    ```js
    var str = 'こんにちは';
    var name = 'もりたさん';
    var newstr = str.concat(name, 'いい天気ですね');
    const str = 'こんにちは';
    const name = 'もりたさん';
    const newstr = str.concat(name, 'いい天気ですね');
    newstr
    'こんにちはもりたさんいい天気ですね'

    @@ -2226,16 +2227,16 @@ target == null
    こちら
    ```js
    var value = 0;
    var target = value || 10
    const value = 0;
    const target = value || 10
    target
    //10
    ```
    はvalueが0の時falseになり10が返る。0の際も代入されるようにしてください
    ```js
    var value = 0;
    var target = (value !== undefined) ? value : 10;
    const value = 0;
    const target = (value !== undefined) ? value : 10;
    value
    //0
    ```
    @@ -2245,21 +2246,21 @@ value
    配列arrayが空ならfalseが返るようにしてください
    ```js
    var array = [];
    const array = [];
    array.length !== 0
    //false
    ```
    **問108**
    こちらは自身のプロパティが定義されていない場合falseが返ることを期待しているがtrueが返る
    ```js
    var obj = {};
    const obj = {};
    obj ? true : false;
    ```
    自身のプロパティを持っていない場合falseが返るようにしてください
    ```js
    var obj = {};
    const obj = {};
    Object.keys(obj).length != 0 ? true : false;
    //false
    ```
    @@ -2278,7 +2279,7 @@ forでループさせるのとforEachで処理する際の違いを教えてく
    function isBigEnough(element, index, array) {
    return (element >= 10);
    }
    var passed = [2, 5, 8, 1, 4].some(isBigEnough);
    const passed = [2, 5, 8, 1, 4].some(isBigEnough);
    // passed は false
    passed = [12, 5, 8, 1, 4].some(isBigEnough);
    // passed は true
    @@ -2326,7 +2327,7 @@ function sum(x, y) {
    return x + y;
    }
    //2
    var pi = 3.141593;
    const pi = 3.141593;
    ```
    @@ -2335,7 +2336,7 @@ var pi = 3.141593;
    export function sum(x, y) {
    return x + y;
    }
    export var pi = 3.141593;
    export const pi = 3.141593;

    //app.js
    import * as math from 'lib/math';
    @@ -2401,12 +2402,12 @@ gen.next().valueを実行すると値が1づつ返ってくるようなGenerator
    ```js
    function* idMaker(){
    var index = 0;
    const index = 0;
    while(true)
    yield index++;
    }

    var gen = idMaker();
    const gen = idMaker();

    console.log(gen.next().value); // 0
    console.log(gen.next().value); // 1
    @@ -2423,9 +2424,9 @@ console.log(gen.next().value); // 2

    //trueなどのプリミティブ値のプロパティにアクセスするとjavascirptはプリミティブ値に対応するコンストラクタからラッパーオブジェクトを作り、そのラッパーオブジェクトのプロパティやメソッドにアクセスできるようになる。(「オブジェクトのように」あつかうことができる。)作られたラッパーオブジェクトはオブジェクトへのアクセスが終わると破棄されて元のプリミティブ値に戻します。
    例えば下記は文字列オブジェクトから文字列を生成しています。
    var string = new String('foo');
    const string = new String('foo');
    string.length;//3 オブジェクトがもつプロパティにアクセスできます。
    var string = 'foo'//プリミティブ値として代入
    const string = 'foo'//プリミティブ値として代入
    string.length //3 文字列プリミティブをオブジェクトとしてアクセス。同じ3を出力していますが内部的に一時的にラッパーオブジェクトを呼び、オブジェクトにアクセス。その後破棄しています

    よく「javascriptは全てがObjectである」と言われるのはこのため
    @@ -2449,7 +2450,7 @@ nullとundefinedの違いを教えてください
    変数fafaの値がnullかどうかを確認してください
    ```js
    var fafa = null;
    const fafa = null;
    console.log(typeof fafa)//Object
    console.log(fafa == undefined)//等値演算子ではtrueになってしまう
    console.log(fafa === null);//true //同値演算子を使う
    @@ -2474,16 +2475,16 @@ div要素を10個作ってidがparentの子要素として追加してくださ
    ```js
    //bad
    var parent = document.getElementById('parent');
    for(var i = 0; i < 10; i++){
    var child = document.createElement('div');
    const parent = document.getElementById('parent');
    for(const i = 0; i < 10; i++){
    const child = document.createElement('div');
    parent.appendChild(child);;
    }

    //good
    var fragment = document.createDocumentFragment();
    for(var i = 0; i < 10; i++){
    var child = document.createElement('div');
    const fragment = document.createDocumentFragment();
    for(const i = 0; i < 10; i++){
    const child = document.createElement('div');
    fragment.appendChild(child);
    }

    @@ -2578,7 +2579,7 @@ console.log(re4[0]);
    下のこちらを使い
    ``` var myRe=/ken*/g; var str2 = 'fafakenfafkenji'; ```
    ``` const myRe=/ken*/g; const str2 = 'fafakenfafkenji'; ```
    文字列の中のkenだけをexecメソッドを使いマッチした文字を全て出力、マッチした文字列の後のインデックスを同時に出力してください
    @@ -2746,7 +2747,7 @@ return 0;
    **問135**
    ```js
    var i = document.getElementById();
    const i = document.getElementById();
    i.parentNode.tagName

    nodeType[1] = ElementNode;
    @@ -2770,8 +2771,8 @@ DOMがある。```#nested```
    要素を削除してください
    ```js
    var i = document.getElementById('top');
    var f = document.getElementById('nested');
    const i = document.getElementById('top');
    const f = document.getElementById('nested');
    i.removeChild(f);
    ```
    @@ -2782,7 +2783,7 @@ nestedの親要素が不明の場合の時nestedを削除してください
    https://developer.mozilla.org/ja/docs/Web/API/Node/removeChild
    ```js
    var node = document.getElementById('nested');
    const node = document.getElementById('nested');

    if (node.parentNode) {
    node.parentNode.removeChild(node);
    @@ -2794,7 +2795,7 @@ if (node.parentNode) {
    topの子要素全て削除してください
    ```js
    var element = document.getElementById('top');
    const element = document.getElementById('top');

    while (element.firstChild) {
    element.removeChild(element.firstChild);
    @@ -2808,7 +2809,7 @@ topの子要素全て削除してください
    ```js
    // Object.prototype汚染
    Object.prototype.bar = 1;
    var foo = {goo: undefined};
    const foo = {goo: undefined};

    foo.bar; // 1
    'bar' in foo; // true
    @@ -2829,14 +2830,14 @@ foo.hasOwnProperty('goo'); // true
    // Object.prototype汚染
    Object.prototype.bar = 1;

    var foo = {moo: 2};
    for(var i in foo) {
    const foo = {moo: 2};
    for(const i in foo) {
    console.log(i); // barとmooが両方とも表示される
    }

    //good
    // 継承されているfoo
    for(var i in foo) {
    for(const i in foo) {
    if (foo.hasOwnProperty(i)) {
    console.log(i);
    }
    @@ -2860,7 +2861,7 @@ Mapは内部で参照元を保持し自分自身で「含まれるオブジェ
    expect : [0, 7, 7]
    ```js
    var ary = [0,0,0];
    const ary = [0,0,0];
    ary.fill(7,1)
    //[0, 7, 7]
    ```
    @@ -2879,8 +2880,8 @@ h3:after {
    h3:after(擬似要素)のcontentプロパティにアクセスしてください
    ```js
    var h3 = document.querySelector('h3');
    var result = getComputedStyle(h3, ':after').content;
    const h3 = document.querySelector('h3');
    const result = getComputedStyle(h3, ':after').content;
    ```
    **問144**
    @@ -2897,14 +2898,14 @@ if(window.matchMedia('(min-width:400)').matches){
    **問145**
    こちらの```var numObj = 12345.6789;```
    こちらの```const numObj = 12345.6789;```
    を小数点以下を丸めてください
    期待する結果
    //12346
    ```js
    var numObj = 12345.6789;
    const numObj = 12345.6789;
    numObj.toFixed();
    //12346
    ```
    @@ -2913,11 +2914,11 @@ numObj.toFixed();
    こちらの
    ```js
    var thing = 'global';
    const thing = 'global';
    function foo(){
    console.log(thing);
    if(true){
    var thing = 'local';
    const thing = 'local';
    console.log(thing);
    }
    }
    @@ -2926,11 +2927,11 @@ foo();
    のconsole.logはそれぞれ何を出力するか答えなさい。またそうなる理由を説明してください
    ```js
    var thing = 'global';
    const thing = 'global';
    function foo(){
    console.log(thing);
    if(true){
    var thing = 'local';
    const thing = 'local';
    console.log(thing);
    }
    }
    @@ -2939,9 +2940,9 @@ foo();
    //local

    //この記述をすると関数内宣言内での変数宣言は巻き上げられてjavascriptは下のように解釈をするから
    var thing = 'global';
    const thing = 'global';
    function foo(){
    var thing;//巻き上げ
    const thing;//巻き上げ
    console.log(thing);
    if(true){
    thing = 'local';
    @@ -2973,8 +2974,8 @@ foo();
    div要素をnodeListとして取得し、Arrayのメソッドで「配列の様なオブジェクト」から配列に変換してください
    ```js
    var likeArray = document.querySelector('div');
    var turnArrayFun = function(obj){
    const likeArray = document.querySelector('div');
    const turnArrayFun = function(obj){
    return [].map.call(obj, function(obj){
    return obj;
    })
    @@ -2994,8 +2995,8 @@ turnArrayFun(likeArray);
    この「既存の内容」より前(1)に```<p>子要素</p>```を挿入してください。但しdocument.writeやinnerHTMLは使わないものとする。
    ```js
    var target = document.querySelector('div#target');
    var html = '<p>子要素</p>';
    const target = document.querySelector('div#target');
    const html = '<p>子要素</p>';
    target.insertAdjacentHTML('afterbegin',html);

    //https://developer.mozilla.org/ja/docs/Web/API/Element/insertAdjacentHTML
    @@ -3016,9 +3017,9 @@ target.insertAdjacentHTML('afterbegin',html);
    上記問題と同じDOM構造でそれぞれtargetより前に挿入(1)、「既存の内容より弟」位置に挿入(2)、targetより後に挿入(3)する記述をしてください
    ```js
    var target = document.querySelector('div#target');
    var html = '<p>子要素</p>';
    var position =
    const target = document.querySelector('div#target');
    const html = '<p>子要素</p>';
    const position =
    beforebegin//(1)
    beforeend//(2)
    afterend //(3)
    @@ -3034,7 +3035,7 @@ target.insertAdjacentHTML(position,html);
    ```js
    const key = 'greeting';
    var objA = {};
    const objA = {};
    objA[key] = 'おはよう';
    objA.greeting
    //'おはよう'
    @@ -3044,7 +3045,7 @@ objA.greeting
    ```js
    const key = 'greeting';
    var objA = {
    const objA = {
    [key] : 'おはよう'
    };
    objA.greeting
    @@ -3054,7 +3055,7 @@ objA.greeting
    こちらの記述
    ```js
    var objA = {
    const objA = {
    add: function(a,b){
    return a + b;
    }
    @@ -3066,7 +3067,7 @@ objA.add(2,5);
    を省略記述してください
    ```js
    var objA = {
    const objA = {
    add(a,b){
    return a + b;
    }
    @@ -3081,7 +3082,7 @@ objA.add(2,5);
    上記の問題のadd関数をobjA内でアロー関数で記述してください
    ```js
    var objA = {
    const objA = {
    add: (a,b)=>{
    return a + b;
    }
    @@ -3095,16 +3096,16 @@ objA.add(2,5);
    このような
    ```js
    var array = ['shibuya','shinjuku','ebisu','shinagawa','tokyo','ueno','ikebukuro'];
    const array = ['shibuya','shinjuku','ebisu','shinagawa','tokyo','ueno','ikebukuro'];
    ```
    配列がある。
    変数aに'shinjuku'、bに'ikebukuro'が代入されるように簡潔に記述してください
    ```js
    var array = ['shibuya','shinjuku','ebisu','shinagawa','tokyo','ueno','ikebukuro'];
    var [,a,,,,, b] = array;
    const array = ['shibuya','shinjuku','ebisu','shinagawa','tokyo','ueno','ikebukuro'];
    const [,a,,,,, b] = array;
    a
    //"shinjuku"
    b
    @@ -3116,19 +3117,19 @@ b
    このような
    ```js
    var obj = {
    const obj = {
    name : 'kenji',
    twon: 'shibuya'
    }
    ```
    objを変数name、twonに代入して出力してください
    ```js
    var obj = {
    const obj = {
    name : 'kenji',
    twon: 'shibuya'
    }
    var {name, twon} = obj;
    const {name, twon} = obj;
    name
    //"kenji"
    twon
    @@ -3137,28 +3138,28 @@ twon
    **問156**
    var name = 'KenjiMorita';
    const name = 'KenjiMorita';
    のKとMだけをそれぞれ変数a,bに入れてください
    ```js
    var name = 'KenjiMorita';
    var [a,,,,,b] = name;
    const name = 'KenjiMorita';
    const [a,,,,,b] = name;

    ```
    **問157**
    変数
    ```js
    var a = 1;
    var b = 'goodby';
    const a = 1;
    const b = 'goodby';
    ```
    のaを'goodby'、bを
    1として出力されるようにしてください(変数のSwap)
    ```js
    var a = 1
    var b = 'goodby'
    const a = 1
    const b = 'goodby'
    b = [a, a = b][0];
    a
    //'goodby'
    @@ -3172,8 +3173,8 @@ b
    上記(問157)と同じ事をECMAScript2015ライクに簡潔に記述してください
    ```js
    var a = 1;
    var b = 'goodby';
    const a = 1;
    const b = 'goodby';
    [a,b] = [b, a]
    ["goodby", 1]

    @@ -3207,7 +3208,7 @@ inputB
    ```js
    document.addEventListener('DOMContentload',function(){
    var target = document.getElementById('inner');
    const target = document.getElementById('inner');
    target.textContent('fafa');
    },false)

    @@ -3251,8 +3252,8 @@ see //http://qiita.com/hosomichi/items/49500fea5fdf43f59c58
    DOMがある。classAより子供のdiv要素のみ取得してください
    ```js
    var classA = document.getElementsByClassName('classA');
    var result = Array.prototype.filter.call(classA,function(classA){
    const classA = document.getElementsByClassName('classA');
    const result = Array.prototype.filter.call(classA,function(classA){
    return classA.nodeName === 'DIV'
    });
    result instanceof Array
    @@ -3272,8 +3273,8 @@ DOMのspanタグの分だけ取得してNodeListをArrayに変えてください
    ```js
    var tag = document.getElementsByTagName('span');
    var array = Array.prototype.slice.call(tag);
    const tag = document.getElementsByTagName('span');
    const array = Array.prototype.slice.call(tag);
    console.log(array instanceof Array );
    ```
    @@ -3301,7 +3302,7 @@ XPathを使ってidがmainのdiv、classにcontentを含むp要素の3番目href
    「3link」を出力してください
    ```js
    var result = document.evaluate(
    const result = document.evaluate(
    '//div[@id="main"]/p[contains(@class,"content")][3]/a[starts-with(@href,"http://example.com")]',
    document,
    null,
    @@ -3310,7 +3311,7 @@ var result = document.evaluate(
    );

    console.log(result.snapshotLength); //1
    var elem = result.snapshotItem(0);
    const elem = result.snapshotItem(0);
    console.log(elem.innerHTML);

    //evalute([path:string],[Node],[null],[XPathResultObject:Type],[null])
    @@ -3343,7 +3344,7 @@ FIRST_ORDERED_NODE_TYPe :9
    clickをしたらclass名がfoo-beforeに変わるtoggleStyleを実装をしてください
    ```js
    var target = document.getElementById('target');
    const target = document.getElementById('target');
    target.onclick = function toggleStyle() {
    this.classList.toggle('foo-after');
    this.classList.toggle('foo-before');
    @@ -3390,9 +3391,9 @@ arry
    {0: "apple", 1: "banana", 2: "orenge"}
    ```js
    var string = "apple banana orenge";
    var arrayed = string.split(" ");
    var obj ={};
    const string = "apple banana orenge";
    const arrayed = string.split(" ");
    const obj ={};
    arrayed.forEach(function(elem,i){
    obj[i] = elem;
    });
    @@ -3401,24 +3402,24 @@ obj


    //Map
    var string = "apple banana orenge";
    var arrayed = string.split(" ");
    var map = new Map();
    var obj ={};
    const string = "apple banana orenge";
    const arrayed = string.split(" ");
    const map = new Map();
    const obj ={};
    arrayed.forEach(function(elem,i){
    map.set(i,elem);
    })
    map
    //{0: "apple", 1: "banana", 2: "orenge"}

    //entries
    var string = "apple banana orenge";
    var arrayed = string.split(" ");
    var newarray =[];
    const string = "apple banana orenge";
    const arrayed = string.split(" ");
    const newarray =[];
    for(value of arrayed.entries()){
    newarray.push(value)
    }
    var map = new Map(newarray)
    const map = new Map(newarray)
    map
    //{0: "apple", 1: "banana", 2: "orenge"}
    ```
    @@ -3458,7 +3459,7 @@ condition && dosomething();
    こちらは
    ```
    for (var i=0; i<5; i++) {
    for (const i=0; i<5; i++) {
    setTimeout(function(){
    console.log(i);
    }, 1000 * (i+1));
    @@ -3473,8 +3474,8 @@ for (var i=0; i<5; i++) {
    その後タイムアウトが実行され、
    iの現在の値(5)が使用されます。

    for (var i=0; i<5; i++) {
    var temp = i;
    for (const i=0; i<5; i++) {
    const temp = i;
    setTimeout(function(){
    console.log(temp);
    }, 1000 * (i+1));
    @@ -3485,8 +3486,8 @@ for (var i=0; i<5; i++) {
    変数の初期化はスコープの先頭に吊り下げられるため、
    これも機能しません。
    実際、前のブロックは次のものと同じです
    var temp;
    for (var i=0; i<5; i++) {
    const temp;
    for (const i=0; i<5; i++) {
    temp = i;
    setTimeout(function(){
    console.log(temp);
    @@ -3498,7 +3499,7 @@ iをコピーする方法はいくつかあります。
    関数を宣言し、iを引数として渡すことによってクロージャを作成することです。
    ここでは、これを自己呼び出し関数として実行します。

    for (var i=0; i<5; i++) {
    for (const i=0; i<5; i++) {
    (function(num){
    setTimeout(function(){
    console.log(num);
    @@ -3530,8 +3531,8 @@ Objectを参照渡しすると代入先の値が変わるとオリジンの値
    ```js
    //一例
    var origin = {name: 'hogehoge',age: 80};
    var obj2 = JSON.parse(JSON.stringify(origin));
    const origin = {name: 'hogehoge',age: 80};
    const obj2 = JSON.parse(JSON.stringify(origin));
    obj2
    //Object {name: "hogehoge", age: 80}
    origin.name = "oo"
    @@ -3776,7 +3777,7 @@ f()
    こちらを使って
    ```js
    var people = [
    const people = [
    { name: "ken",
    family: {
    mother: "jone Smith"
    @@ -3799,7 +3800,7 @@ var people = [
    出力になるように実装してください。
    ```js
    var people = [
    const people = [
    { name: "ken",
    family: {
    mother: "jone Smith"
    @@ -3812,7 +3813,7 @@ var people = [
    },
    age: 27
    }];
    for (var {name: n, family: {mother : f}} of people){
    for (const {name: n, family: {mother : f}} of people){
    console.log("Name " + n + ", Mother: " + f);
    }
    //Name ken, Mother: jone Smith
    @@ -3824,7 +3825,7 @@ for (var {name: n, family: {mother : f}} of people){
    こちら
    ```js
    var metadata = {
    const metadata = {
    title: 'Scratchpad',
    translations: [
    {
    @@ -3841,7 +3842,7 @@ var metadata = {
    のtitleをenglishTitleとして、translationsの中のtitleをlocalTitleとしてそれぞれ変数に代入してconsole.log出力してください
    ```js
    var metadata = {
    const metadata = {
    title: 'Scratchpad',
    translations: [
    {
    @@ -3854,7 +3855,7 @@ var metadata = {
    ],
    url: 'kenjimorita.jp/JavaScript'
    };
    var {title: englishTitle, translations: [{title: localeTitle}]} = metadata;
    const {title: englishTitle, translations: [{title: localeTitle}]} = metadata;
    console.log(englishTitle, localeTitle);
    //'Scratchpad'
    //'JavaScript'
    @@ -3868,9 +3869,9 @@ console.log(englishTitle, localeTitle);
    ```js
    function drawES5Chart(options) {
    options = options === undefined ? {} : options;
    var size = options.size === undefined ? 'big' : options.size;
    var cords = options.cords === undefined ? { x: 0, y: 0 } : options.cords;
    var radius = options.radius === undefined ? 25 : options.radius;
    const size = options.size === undefined ? 'big' : options.size;
    const cords = options.cords === undefined ? { x: 0, y: 0 } : options.cords;
    const radius = options.radius === undefined ? 25 : options.radius;
    console.log(size, cords, radius);
    }
    drawES5Chart({
    @@ -3924,7 +3925,7 @@ Object.keys(nodeList).forEach(function(key){
    ```js

    function add (){console.log(this.x) };
    var obj = {x: 5};
    const obj = {x: 5};
    add.apply(obj)
    //5
    ```
    @@ -3947,28 +3948,28 @@ add.call({x: 3}, 5, 6)
    下のような記述がある。
    ```js
    var int = 8;
    var module = {
    const int = 8;
    const module = {
    int: 4,
    fn : function(){return this.int;}
    }
    ```
    module.fnを別の変数にbindして呼び出し、4を出力してください。
    ```js
    var int = 8;
    var module = {
    const int = 8;
    const module = {
    int: 4,
    fn : function(){return this.int;}
    }
    module.fn()
    //4
    var fnn = module.fn
    const fnn = module.fn
    fnn()
    //8

    //bindして呼び出し
    var fnn = module.fn.bind(module)
    const fnn = module.fn.bind(module)
    fnn()
    //生成する関数にもともとのthis参照しているオブジェクトを束縛させる必要がある
    ```
    @@ -3987,22 +3988,22 @@ list(2,3,4);
    function list (){
    return Array.prototype.slice.call(arguments);
    }
    var bindedList = list.bind(null, 1);
    const bindedList = list.bind(null, 1);
    bindedList(3,4,5)
    //[1, 3, 4, 5]
    ```
    **問194**
    ```<ul id="list"></ul>```がある。
    document.createFragmentをつかって```var array = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"];```
    document.createFragmentをつかって```const array = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"];```
    がliのtextContentとなるようなDOMを作成してください。
    ```js
    var list = document.getElementById('list');
    var fragment = document.createDocumentFragment();
    var array = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"];
    var newnode = array.forEach(function(elem){
    var li = document.createElement("li");
    const list = document.getElementById('list');
    const fragment = document.createDocumentFragment();
    const array = ["Internet Explorer", "Mozilla Firefox", "Safari", "Chrome", "Opera"];
    const newnode = array.forEach(function(elem){
    const li = document.createElement("li");
    li.textContent = elem;
    fragment.appendChild(li);
    })
    @@ -4065,7 +4066,7 @@ localStrage.setItem('foo','fafa');
    localStrage.getItem('foo');
    localStorage.removeItem('foo')
    localStorage.clear();
    var key = localStorage.key(0)
    const key = localStorage.key(0)
    console.log(key + 'のストレージは' + localStorage[key]);
    ```
    @@ -4086,7 +4087,7 @@ console.log(key + 'のストレージは' + localStorage[key]);
    **問201**
    ローカルストレージの値を存在するだけ列挙してください
    ```js
    for (var i = 0; i < localStorage.length; i++){
    for (const i = 0; i < localStorage.length; i++){
    console.log(localStorage.key(i))
    }
    ```
    @@ -4132,7 +4133,7 @@ function CreateId(id){
    CreateId.prototype.get = function(){
    console.log(this.id);
    }
    var create = new CreateId(10);
    const create = new CreateId(10);
    create.get()//10
    setTimeout(create.get, 1000);
    ```
    @@ -4154,7 +4155,7 @@ setTimeout(()=> {create.get}, 1000);
    こちらの
    ```js
    function Person() {
    var self = this;
    const self = this;
    self.age = 0;

    setInterval(function() {
    @@ -4163,7 +4164,7 @@ function Person() {
    self.age++;
    }, 1000);
    }
    var p = new Person();
    const p = new Person();
    p
    //{age: 1} //1秒ごとに1足される
    ```
    @@ -4178,7 +4179,7 @@ function Person() {
    }, 1000);
    }

    var p = new Person();
    const p = new Person();
    ```
    @@ -4267,10 +4268,10 @@ console.log(obj.prop); // 456
    {id: "12345", category: "script", isname: "true"}
    ```js
    var locationsearch = '?id=12345&category=script&isname=true';
    var result = {};
    const locationsearch = '?id=12345&category=script&isname=true';
    const result = {};
    locationsearch.substring(1).split("&").forEach(function(ele, i){
    var key = ele.split("=");
    const key = ele.split("=");
    result[key[0]] = decodeURIComponent(key[1]);
    })
    ```
    @@ -4286,7 +4287,7 @@ locationsearch.substring(1).split("&").forEach(function(ele, i){
    ```js
    var deduped = [1,1,'a','a'].filter(function(x, i, arr){
    const deduped = [1,1,'a','a'].filter(function(x, i, arr){
    return arr.indexOf(x) === i;
    })
    deduped
    @@ -4334,7 +4335,7 @@ flatArray
    ```js
    const arr = [];
    for (var i=0; i < 3; i++) {
    for (const i=0; i < 3; i++) {
    arr.push(() => i);
    }
    arr.map(x => x()); // [3,3,3]
    @@ -4444,9 +4445,9 @@ class Faaaa extends Faa {
    }
    }

    var eee = new Faa('kenji');
    const eee = new Faa('kenji');
    eee.speak();
    var iii = new Faaaa('morita');
    const iii = new Faaaa('morita');
    iii.getSpeak();
    eee.speak();
    ```
    @@ -4508,8 +4509,8 @@ for (const x of new IterableArguments('hello', 'world')) {
    定義と同時に実行する関数を作ってください
    ```js
    var dimension = function(radius, height){
    var dimension = radius * radius * Math.PI;
    const dimension = function(radius, height){
    const dimension = radius * radius * Math.PI;
    return dimension * height / 3;
    }(10,20);
    console.log(dimension);
    @@ -4521,7 +4522,7 @@ console.log(dimension);
    オブジェクトのプロパティが存在するかどうか
    ```js
    var obj = {
    const obj = {
    width: 20
    }
    if(!!obj.height){
    @@ -4548,42 +4549,41 @@ function multiply(x, y){
    }
    function withLogging(wrappedFunction){
    return function(x, y){
    var result = wrappedFunction(x, y);
    const result = wrappedFunction(x, y);
    console.log('result', result);
    return result;
    };
    }

    var addAndLog = withLogging(add);
    const addAndLog = withLogging(add);
    addAndLog(1, 2)
    //result 3
    //3

    var multiplyAndLog = withLogging(multiply)
    const multiplyAndLog = withLogging(multiply)
    multiplyAndLog(40,4)
    //result 160

    ```
    **問221**
    document内のh1を全て取得し、インデックス1番目のh1を削った残りを返してください
    ```js
    var hoge = document.querySelectorAll('h1');
    var newHoge = Array.prototype.slice.call(hoge, 1);
    const hoge = document.querySelectorAll('h1');
    const newHoge = Array.prototype.slice.call(hoge, 1);

    ```
    **問222**
    ```var a = 'aabbccdde1e23ffgg'; ``````var b = 'aabbccdde1e23ffgg';```がある。
    ```const a = 'aabbccdde1e23ffgg'; ``````const b = 'aabbccdde1e23ffgg';```がある。
    aとbを比較してaの方が先に数値が現れる場合trueを返してください
    ```js
    var a = 'aabbccdde1e23ffgg';
    var b = 'aabbccddee123ffgg';
    const a = 'aabbccdde1e23ffgg';
    const b = 'aabbccddee123ffgg';

    a.search(/\d/) < b.search(/\d/);
    //true
    @@ -4594,8 +4594,8 @@ a.search(/\d/) < b.search(/\d/);
    ```<div>abuout me</div>```divタグに囲まれた文字列を配列divArrayに格納しなさい
    ```js
    var div = '<div>about me</div>';
    var divarray=[];
    const div = '<div>about me</div>';
    const divarray=[];
    divarray.push(/\<div\>(.+)\<\/div\>/.exec(div)[1])
    divarray
    //['about me']
    @@ -4607,8 +4607,8 @@ divarray
    WIP
    ```js
    var i = 0;
    var array = [];
    const i = 0;
    const array = [];
    do {
    array.push(Math.pow(2,i));
    i += 1;
    @@ -4623,7 +4623,7 @@ i += 1;
    1980年8月1日5時55分を表すDateオブジェクトを生成してください
    ```js
    var d = new Date('1980/8/1 5:55');
    const d = new Date('1980/8/1 5:55');
    //Fri Aug 01 1980 05:55:00 GMT+0900 (JST)

    ```
    @@ -4635,7 +4635,7 @@ var d = new Date('1980/8/1 5:55');
    上で作成した日時を現地フォーマットで出力してください
    ```js
    var d = new Date('1980/8/1 5:55');
    const d = new Date('1980/8/1 5:55');
    d.toLocaleString();
    //'2008/7/1 5:55:00'

    @@ -4652,7 +4652,7 @@ WIP
    上で作成した時間を現地フォーマットで出力してください
    ```js
    var d = new Date('1980/8/1 5:55');
    const d = new Date('1980/8/1 5:55');
    d.toLocaleTimeString();
    //'5:55:00'

    @@ -4664,9 +4664,9 @@ d.toLocaleTimeString();
    **問228**
    var ary = ['aaa', 'bbb', 'ccc'];に文字列'eee'を先頭に追加してください
    const ary = ['aaa', 'bbb', 'ccc'];に文字列'eee'を先頭に追加してください
    ```js
    var ary = ['aaa', 'bbb', 'ccc'];
    const ary = ['aaa', 'bbb', 'ccc'];
    ary.unshift('eee');
    //4
    ary
    @@ -4677,12 +4677,12 @@ ary
    **問229**
    こちらの変数を使って
    var ary = [0, 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10];
    const ary = [0, 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10];
    2でも3でも割り切れない数を抽出した配列を生成してください
    ```js
    var ary = [0, 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10];
    var newAry = ary.filter(function(elem){
    const ary = [0, 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10];
    const newAry = ary.filter(function(elem){
    if (elem % 3 !== 0 && elem % 2 !== 0){
    return elem
    }
    @@ -4745,7 +4745,7 @@ encodeURI(url)
    **問233**
    ```var s = 'aaa,bbb,ccc,ddd';```
    ```const s = 'aaa,bbb,ccc,ddd';```
    を使って、,を/に置換した文字列```aaa/bbb/ccc/ddd```を出力してください。ただしreplaceメソッドは使用しないこととする
    ```js
    @@ -4762,17 +4762,17 @@ s
    **問234**
    下の変数sにある
    ```var s = 'aaa<div>bbb</div>ccc<div>ddd</div>eee';```
    ```const s = 'aaa<div>bbb</div>ccc<div>ddd</div>eee';```
    divの中にあるtextを全て出力してください
    ```js
    var s = 'aaa<div>bbb</div>ccc<div>ddd</div>eee';
    var divStringAry = [];
    var regexp = /<div>.*?<\/div>/g;
    var result = regexp.exec(s);
    const s = 'aaa<div>bbb</div>ccc<div>ddd</div>eee';
    const divStringAry = [];
    const regexp = /<div>.*?<\/div>/g;
    const result = regexp.exec(s);
    while(result != null){
    var divStr = result[0]
    const divStr = result[0]
    divStr = divStr.substring('<div>'.length,
    divStr.length - '</div>'.length);
    divStringAry.push(divStr);
    @@ -4793,8 +4793,8 @@ divStringAry.join('\n')
    ```js

    var ary = [];
    var i = 0;
    const ary = [];
    const i = 0;
    do {
    ary[i] = Math.pow(2, i);
    i += 1;
    @@ -4803,8 +4803,8 @@ ary
    //[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]

    //別解
    var ary = [];
    for(var n = 0; n <= 10; n++){
    const ary = [];
    for(const n = 0; n <= 10; n++){
    ary[n] = Math.pow(2, n);
    }
    ```
    @@ -4815,10 +4815,10 @@ for(var n = 0; n <= 10; n++){
    今年の各月の最終日を配列に格納してくださいl。インデックスは各月と一致する数値とする。
    ```js
    var ary = [];
    var temp = new Date();
    for (var i = 1; i <= 12; i++){
    var d = 28;
    const ary = [];
    const temp = new Date();
    for (const i = 1; i <= 12; i++){
    const d = 28;
    temp.setMonth(i - 1, d);
    while(temp.getMonth() == i - 1){//次の月になるまでroop
    d++;
    @@ -4889,14 +4889,14 @@ kenjiを継承しjobを自身のプロパティとしてもつcompKenjiを作成

    ```js
    var Person = {
    const Person = {
    say: function(){
    console.log('my name is' + this.name + '。' + '職業は' + this.job + 'です');
    }
    }
    var kenji = Object.create(Person, {name :{value: 'kenji' }});
    var compKenji = Object.create(morita, {job: {value: 'JavascriptEngneer'}});
    const kenji = Object.create(Person, {name :{value: 'kenji' }});
    const compKenji = Object.create(morita, {job: {value: 'JavascriptEngneer'}});
    compKenji.say()
    'my name is morita。JavascriptEngneer'
    @@ -4924,7 +4924,7 @@ o = Object.create(Constructor.prototype);

    **241**

    ```var o = Object.create({},{p: {value: 32}});```
    ```const o = Object.create({},{p: {value: 32}});```
    を書き換えtrue、列挙true、変更trueとして新たにオブジェクトを生成してください。

    ```js
    @@ -4935,7 +4935,7 @@ o2.p = 54;
    //54
    列挙
    for (var prop in o2){
    for (const prop in o2){
    console.log(prop)
    }
    //p
    @@ -4993,7 +4993,7 @@ n
    こちらの評価は

    ```
    var n = {value: 0};
    const n = {value: 0};
    if(n.value){
    //something
    }
    @@ -5010,7 +5010,7 @@ if(n.value != null){//something}
    **245**
    オブジェクトの存在チェックをしてあったら実行している。
    ```js
    var o = {f: function(){console.log('JS')}};
    const o = {f: function(){console.log('JS')}};
    if(o){
    if(o.f){
    o.f();
    @@ -5020,7 +5020,7 @@ if(o){
    より端的な記述をしてください。

    ```js
    var o = {f: function(){console.log('JS')}};
    const o = {f: function(){console.log('JS')}};
    o && o.f && o.f();
    //同じ様なイデオムで代入の際に括弧でくくらないとエラーが起きることに注意してください
    @@ -5029,26 +5029,26 @@ o && o.f && o.f();


    **246**
    ```var v```の値を確実に数値にしたい。
    ```const v```の値を確実に数値にしたい。
    'a'が入ってきた場合NaNではなく0を代入するようにしてください。

    ```js
    var n = +v || 0;
    const n = +v || 0;
    ```

    **247**
    ```var v ```を整数化してください
    ```const v ```を整数化してください

    ```js
    var i = v | 0;
    const i = v | 0;
    ```

    **248**
    下の様な場合、
    ```js
    var insEmp1 = new Emp();
    var insEmp2= new Emp();
    const insEmp1 = new Emp();
    const insEmp2= new Emp();
    insEmp2.name = "kenji";
    insEmp2.name;
    //"kenji"
    @@ -5064,8 +5064,8 @@ Empがnameを持っていない場合Emp1は即座に更新されない。

    ```js
    function Emp(){};
    var insEmp1 = new Emp();
    var insEmp2 = new Emp();
    const insEmp1 = new Emp();
    const insEmp2 = new Emp();
    Emp.prototype.name = "kenji";
    insEmp1.name
    @@ -5082,7 +5082,7 @@ ObjectとMapの違いを教えてください
    ・Objectのkeyはstring型、Mapは任意の型を指定できる
    ・Objectのsizeは手動で調べる必要がある、MapはMap.size()
    ・Objectの反復は順番を保証しない,Mapの反復は要素の挿入順
    ・Objectはデフォルトでプロパティを持つ(var map = Object.create(null)で回避できる)
    ・Objectはデフォルトでプロパティを持つ(const map = Object.create(null)で回避できる)
    //ObjectかMapか、使うべきところ
    @@ -5097,23 +5097,23 @@ http://programmers.stackexchange.com/questions/285881/any-point-in-using-es6-map
    http://stackoverflow.com/questions/18541940/map-vs-object-in-javascript
    Object:
    var o = {};
    var o = Object.create(null);
    const o = {};
    const o = Object.create(null);
    o.key = 1;
    o.key += 10;
    for(let k in o) o[k]++;
    var sum = 0;
    const sum = 0;
    if('key' in o);
    if(o.hasOwnProperty('key'));
    delete(o.key);
    Object.keys(o).length
    Map:
    var m = new Map();
    const m = new Map();
    m.set('key', 1);
    m.set('key', m.get('key') + 10);
    m.foreach((k, v) => m.set(k, m.get(k) + 1));
    for(let k of m.keys()) m.set(k, m.get(k) + 1);
    var sum = 0;
    const sum = 0;
    for(let v of m.values()) sum += v;
    if(m.has('key'));
    m.delete('key');
    @@ -5132,10 +5132,10 @@ pop、push、reverse、shift、sort、splice、unshilft

    **251**

    ```var arr = ['one', 'two', 'three']```においてarrを不変オブジェクトに変更してください。
    ```const arr = ['one', 'two', 'three']```においてarrを不変オブジェクトに変更してください。

    ```js
    var arr = ['one', 'two', 'three']
    const arr = ['one', 'two', 'three']
    Object.freeze(arr);
    arr.sort();
    //Uncaught TypeError: Cannot assign to read only property '1' of object '[object Array]'
    @@ -5149,14 +5149,14 @@ console.log(obj)
    //ex2
    //「子供」までは面倒みない
    var obj2 = Object.freeze({a: 1, b : {a: 2}})
    const obj2 = Object.freeze({a: 1, b : {a: 2}})
    obj2.b.a = 4
    console.log(obj2.b.a);
    //4
    //ex3
    //子供も凍結させる
    var obj3 = Object.freeze({a: 1, b: Object.freeze({a: 2})})
    const obj3 = Object.freeze({a: 1, b: Object.freeze({a: 2})})
    obj3.b.a = 4
    console.log(obj3.b.a)
    //2
    @@ -5168,7 +5168,7 @@ console.log(obj3.b.a)
    このようなobjがあります。

    ```js
    var obj = {
    const obj = {
    'prop1': 'value1',
    'prop2': 'value2',
    'prop3': 'value3'
    @@ -5186,12 +5186,12 @@ JSON.stringifyを使って
    ように出力されるようにしてください(prop3が出力されていない。1タブ分インデントされていることに注意)

    ```js
    var obj = {
    const obj = {
    'prop1': 'value1',
    'prop2': 'value2',
    'prop3': 'value3'
    }
    var str = JSON.stringify(obj, ['prop1', 'prop2'], '\t');
    const str = JSON.stringify(obj, ['prop1', 'prop2'], '\t');
    str
    //
    "{
    @@ -5212,7 +5212,7 @@ function selectedProperties(key, val) {
    }
    return;
    }
    var str = JSON.stringify(obj, selectedProperties, '\t');
    const str = JSON.stringify(obj, selectedProperties, '\t');
    str
    //
    {
    @@ -5239,19 +5239,19 @@ e.g const obj = {add : function(){some}};
    ```

    **254**
    var obj = { foo: 'bar', baz: 42 }; をMapオブジェクトに変換してください
    const obj = { foo: 'bar', baz: 42 }; をMapオブジェクトに変換してください

    ```js
    var obj = { foo: 'bar', baz: 42 };
    var map = new Map(Object.entries(obj));
    const obj = { foo: 'bar', baz: 42 };
    const map = new Map(Object.entries(obj));
    console.log(map); // Map { foo: 'bar', baz: 42 }
    ```

    **255**

    ```js
    var Emiiter = {
    const Emiiter = {
    callbacks : [],
    register : function(fn){
    this.callbacks.push(fn);
    @@ -5272,7 +5272,7 @@ Emiiter.register(function(){console.log('2')});
    こちらはcolorの条件でそれぞれの関数を実行する記述です。

    ```js
    var color = "black";
    const color = "black";
    function printBlack(){
    console.log('black')
    }
    @@ -5334,7 +5334,7 @@ switch(true) {
    可能な限りswitch文を使用しないようにするためオブジェクトを介して上記のようにcolorに合った関数を実行してください
    ```js
    var color = "black";
    const color = "black";

    function printBlack(){
    console.log('black')
    @@ -5348,7 +5348,7 @@ function printBlue(){
    function printYellow(){
    console.log('yellow')
    }
    var colorObj = {
    const colorObj = {
    'black': printBlack,
    'red': printRed,
    'blue': printBlue,
    @@ -5366,8 +5366,8 @@ if (color in colorObj) {
    ```js

    function toObject(arry){
    var obj = {};
    for(var i = 0; i < arry.length; i++){
    const obj = {};
    for(const i = 0; i < arry.length; i++){
    obj[i] = arry[i];
    }
    return obj
    @@ -5384,7 +5384,7 @@ toObject(arry);
    ```js
    let html = '';
    const count = 10;
    for(var i = 0;i < count; i++){
    for(const i = 0;i < count; i++){
    html += 'hai!!';
    }
    document.querySelector('#mngb').innerHtml = html;
    @@ -5394,9 +5394,9 @@ document.querySelector('#mngb').innerHtml = html;
    をより高速な書き方をしてください
    ```js
    var html = [];
    var count = 10;
    for(var i = 0; i < count; i++){
    const html = [];
    const count = 10;
    for(const i = 0; i < count; i++){
    html.push('hei!!');
    }
    document.querySelector('#mngb').innerHtml = html.join('');
    @@ -5506,7 +5506,7 @@ obj

    //3
    [{a: 1},{b: 3}].reduce(function(result, item){
    var key = Object.keys(item)[0]
    const key = Object.keys(item)[0]
    result[key] = item[key];
    return result;
    },{})
    @@ -5565,13 +5565,13 @@ sortedCharacters === characters
    ジェネレーター関数を使って1ずつ値を出力してください。
    ```js
    var generatorFunction = function* (){
    var i = 0;
    const generatorFunction = function* (){
    const i = 0;
    while (true) {
    yield i ++;
    }
    }
    var iterator = generatorFunction();
    const iterator = generatorFunction();
    iterator.next().value;
    //0
    iterator.next().value;
    @@ -5582,11 +5582,11 @@ iterator.next().value;
    generator関数がyieldの完了まで前進したら'finish'という文字列を返してください
    ```js
    var gen = function* (){
    const gen = function* (){
    yield 'foo';
    return 'finish';
    }
    var iterator = gen();
    const iterator = gen();
    iterator.next();
    //'foo'
    iterator.next();
    @@ -5597,14 +5597,14 @@ iterator.next();
    数値1から3までの値を返すgenarator関数で生成されたiteratableをfor-of文に使い値を出力してください。(その際for-of文での戻り値を捨てていることを確認してください。)
    ```js
    var fun = function * (){
    const fun = function * (){
    yield 1;
    yield 2;
    yield 3;
    return 4;//for-of文では捨てられる
    }

    var iterator = fun();
    const iterator = fun();
    for(index of iterator){
    console.log(index)
    }
    @@ -5644,7 +5644,7 @@ for (index of foo()){
    値が'a'ならgenerator関数内のtry-catch内で値をバックアップ、'b'なら呼び出し元で例外を発生させるgenerator関数を定義してください。
    ```js
    var generatorFunction = function * (){
    const generatorFunction = function * (){
    while (true){
    try {
    yield;
    @@ -5656,7 +5656,7 @@ var generatorFunction = function * (){
    }
    }
    };
    var iterator = generatorFunction();
    const iterator = generatorFunction();
    iterator.next();
    try {
    iterator.throw('a');
    @@ -5711,7 +5711,7 @@ const curry = (method, ...args) => {
    const controller = (generator) => {
    const iterator = generator();
    const advancer = (response) => {
    var state;
    const state;
    state = iterator.next(response);
    if (!state.done) {
    state.value(advancer);
    @@ -5781,7 +5781,7 @@ const create = function(i){
    return `<img src='${i}.png'>`;
    }
    const arry = [];
    for(var i of ge(1,7)){
    for(const i of ge(1,7)){
    arry.push(create(i))
    }
    ```
    @@ -5791,12 +5791,12 @@ for(var i of ge(1,7)){
    for-ofに渡すと1~10までの数値を返すitarableなオブジェクトを自作してください。
    ```js
    var obj = {}; // イテラブルなオブジェクト
    const obj = {}; // イテラブルなオブジェクト
    obj[Symbol.iterator] = function(){//イテレータを返す関数を代入
    var iterator = {}; // イテレータ
    var num = 1;
    const iterator = {}; // イテレータ
    const num = 1;
    iterator.next = function(){//next実行してリザルトを返す関数を代入
    var iteratorResult = (num <= 10)
    const iteratorResult = (num <= 10)
    ? { value: num++, done: false }
    : { value: undefined, done: true };
    return iteratorResult; // イテレータリザルトを返す
    @@ -5847,11 +5847,11 @@ iterator.next(1).value
    ```js
    function* foo(x) {
    var y = 2 * (yield (x + 1));
    var z = yield (y / 3);
    const y = 2 * (yield (x + 1));
    const z = yield (y / 3);
    return (x + y + z);
    }
    var it = foo(5);
    const it = foo(5);
    it.next();//1
    it.next(12);//2
    it.next(13);//3
    @@ -5861,11 +5861,11 @@ it.next(13);//3
    ```js
    function* foo(x) {
    var y = 2 * (yield (x + 1));
    var z = yield (y / 3);//2回目で返すのはyield式の結果までで結果はzに代入されない//3回目のnext引数がzに入る
    const y = 2 * (yield (x + 1));
    const z = yield (y / 3);//2回目で返すのはyield式の結果までで結果はzに代入されない//3回目のnext引数がzに入る
    return (x + y + z);
    }
    var it = foo(5);
    const it = foo(5);

    it.next();
    //{value: 6, done: false}
    @@ -6063,7 +6063,7 @@ Reflect.deletePropery(target, 'key')
    こちらはReflect.getを使って
    ```js
    var obj = {a : 1}
    const obj = {a : 1}
    Reflct.get(obj, "a")
    //1
    ```
    @@ -6082,7 +6082,7 @@ obj["a"]
    //undefinedになります。実行時objの型が適切か気づくことができます。

    e.g
    var obj = 1;//オブジェクトが入ってくる想定のobjにプリミティブ型を代入
    const obj = 1;//オブジェクトが入ってくる想定のobjにプリミティブ型を代入
    Reflect.get(obj, 1)
    //Uncaught TypeError: Reflect.get called on non-object

    @@ -6096,7 +6096,7 @@ Reflect.applyとはどのようなものですか。
    ```js
    //このようにthis.を参照するfun関数を引数を伴って使う必要がある場合、
    var ctx = {
    const ctx = {
    num : 5
    }
    function fun (a, b, c){
    @@ -6159,13 +6159,13 @@ p.c(cは設定されていない任意のプロパティ)
    //37
    ```js
    var handler = {
    const handler = {
    get: function(target, name){
    return name in target ? target[name] : 37
    }
    }

    var p = new Proxy({}, handler);
    const p = new Proxy({}, handler);
    p.a = 1
    p.a
    //1
    @@ -6188,7 +6188,7 @@ Reflect.has({a: 1}, 'toString');
    Errorオブジェクトのインスタンスにmessageとして"エラーが発生しました"を代入エラーをthrowしてください
    ```
    var err = new Error();
    const err = new Error();
    err.message = "エラーが発生しました"
    throw err

    @@ -6201,7 +6201,7 @@ throw new Error("エラーが発生しました。");
    obj.aに数値以外のものが代入されるとsetterでErrorを投げ、number型ならaに代入。getterはaを返すobjを作ってください。
    ```js
    var obj = {
    const obj = {
    _a : 0,
    get a(){return this._a; },
    set a(n){
    @@ -6230,8 +6230,8 @@ var obj = {
    ```js

    var foo = document.getElementById('foo');
    for(var i = 0; i < foo.classList.length; i++) {
    const foo = document.getElementById('foo');
    for(const i = 0; i < foo.classList.length; i++) {
    console.log(foo.classList[i]);
    }

    @@ -6262,7 +6262,7 @@ else
    の中にbazがあることを真偽値で出力してください
    ```js
    var foo = document.getElementById('foo');
    const foo = document.getElementById('foo');
    foo.classList.contains('foo');

    //対応ブラウザバージョン
    @@ -6280,7 +6280,7 @@ foo.classList.contains('foo');
    にfafaというclass名を追加してbarを削除してください
    ```js
    var foo = document.getElementById('foo');
    const foo = document.getElementById('foo');
    foo.classList.add('fafa');
    foo.classList.remove('bar');

    @@ -6320,7 +6320,7 @@ request.send();
    ```
    **問292**
    var data = { foo: 'abc', bar: 100 }
    const data = { foo: 'abc', bar: 100 }
    このようなdataをPOSTで送れるようにしてください
    期待する結果
    @@ -6347,7 +6347,7 @@ $(selector).each(function(i, el){
    と同じ処理をJSで記述してください
    ```js
    var elements = document.querySelectorAll(selector);
    const elements = document.querySelectorAll(selector);
    Array.prototype.forEach.call(elements, function(el, i){
    something...
    });
    @@ -6399,7 +6399,7 @@ $(el).hasClass(className);
    と同じ処理をJSで記述してください
    ```js
    var el = document.getElementById('container')
    const el = document.getElementById('container')
    if (el.classList){
    el.classList.contains(className);
    } else {
    @@ -6419,7 +6419,7 @@ $(el).parent();
    と同じことをJSで記述してください
    ```js
    var el = document.getElementById('container')
    const el = document.getElementById('container')
    el.nextElementSibling
    el.parentNode
    ```
    @@ -6436,7 +6436,7 @@ $(el).offset();
    と同じ値を含むオブジェクトを取得できるようにJSで記述してください。
    ```js
    var rect = el.getBoundingClientRect();
    const rect = el.getBoundingClientRect();
    rect
    //{top:11, height:11, left:11, right:11, bottom:11, width:11}

    @@ -6503,8 +6503,8 @@ $(el).toggleClass(className);
    if (el.classList) {
    el.classList.toggle(className);
    } else {
    var classes = el.className.split(' ');
    var existingIndex = classes.indexOf(className);
    const classes = el.className.split(' ');
    const existingIndex = classes.indexOf(className);

    if (existingIndex >= 0)
    classes.splice(existingIndex, 1);
    @@ -6527,8 +6527,8 @@ $.parseHTML(htmlString);
    ```js
    var parseHTML = function(str) {
    var tmp = document.implementation.createHTMLDocument();
    const parseHTML = function(str) {
    const tmp = document.implementation.createHTMLDocument();
    tmp.body.innerHTML = str;
    return tmp.body.children;
    };
    @@ -6556,7 +6556,7 @@ el.addEventListener(eventName, eventHandler);
    ```js
    function onReady(fnc) {
    var readyState = document.readyState;
    const readyState = document.readyState;
    if (readyState === 'interactive' || readyState === 'complete') {
    fnc();
    } else {
    @@ -6666,7 +6666,7 @@ Promseオブジェクト作成時にresolveに数値1を渡すコールバック
    続くthenメソッドで2を足した値を出力してください。
    ```js
    var promise1 = new Promise(function(resolve, reject){
    const promise1 = new Promise(function(resolve, reject){
    resolve(1);
    })
    promise1.then(function(val){
    @@ -6687,7 +6687,7 @@ Promiseオブジェクトを使ってGETメソッドリクエスト,list.json
    ```js
    function get(url) {
    return new Promise(function(resolve, reject) {
    var req = new XMLHttpRequest();
    const req = new XMLHttpRequest();
    req.open('GET', url);
    req.onload = function() {
    if (req.status == 200) {
    @@ -6743,7 +6743,7 @@ Promiseを使って0.5秒後毎に文字列の出力がされる非同期処理

    ```js
    function f (name, time){
    var done = new Promise(function(resolve){
    const done = new Promise(function(resolve){
    setTimeout(function(){
    console.log(name)
    resolve();
    @@ -6777,7 +6777,7 @@ f().then(()=> f(500))//「fした後に~する」の中身を実装。この場

    ```js
    function f (name, time){
    var done = new Promise(function(resolve){
    const done = new Promise(function(resolve){
    setTimeout(function(){
    console.log(name)
    @@ -6786,7 +6786,7 @@ function f (name, time){
    });
    return done
    };
    var i = Promise.all([f('morita', 500),f('kkk', 500),f('jji', 500)])
    const i = Promise.all([f('morita', 500),f('kkk', 500),f('jji', 500)])
    i.then(()=> console.log("done"))
    ```
    @@ -6802,7 +6802,7 @@ i.then(()=> console.log("done"))
    ```js
    function hidouki(url, num){
    return new Promise(function(resolve, reject){
    var req = new XMLHttpRequest();
    const req = new XMLHttpRequest();
    req.open('GET', url);
    req.onload = function () {
    console.log(num)
    @@ -6819,7 +6819,7 @@ i.then(()=> console.log("done"))
    })
    }
    async function asyncFunction (url, num){
    var result = await hidouki(url , num);
    const result = await hidouki(url , num);
    console.log(result);
    return result;
    }
    @@ -6840,7 +6840,7 @@ i.then(()=> console.log("done"))
    ```js
    function hidouki(url, num){
    return new Promise(function(resolve, reject){
    var req = new XMLHttpRequest();
    const req = new XMLHttpRequest();
    req.open('GET', url);
    req.onload = function () {
    console.log(num)
    @@ -6885,7 +6885,7 @@ async function asyncFunction (){
    ```js
    const promiseFun = co.wrap( function* (url){
    return new Promise(function(resolve, reject){
    var req = new XMLHttpRequest();
    const req = new XMLHttpRequest();
    req.open('GET', url, true);
    req.onload = function(){
    if(req.status == 200){
    @@ -6904,7 +6904,7 @@ const promiseFun = co.wrap( function* (url){
    });
    })
    co(function* (){
    var res = yield [
    const res = yield [
    promiseFun('http://localhost:3000/posts'),
    promiseFun('http://localhost:3000/profile'),
    promiseFun('http://localhost:3000/state'),
    @@ -6919,7 +6919,7 @@ const promiseFun = co.wrap( function* (url){
    coを使ってgeneratorをラップしたfnを実行して、Promiseがresolveするまで処理を止める記述をしてください。※Promise.resolveで任意の値をすぐ返してok

    ```js
    var fn = co.wrap(function* (fa){
    const fn = co.wrap(function* (fa){
    return yield Promise.resolve(fa);
    });
    fn(true).then(function(val){console.log(val)})
    @@ -6934,8 +6934,8 @@ coを使って、1から始まり1秒ごとにインクルメントされた値
    })
    };
    var num = co.wrap(function* (num){
    for(var i = 1; i <= num; i++) {
    const num = co.wrap(function* (num){
    for(const i = 1; i <= num; i++) {
    yield sleep(i);
    console.log(i)
    }
    @@ -7097,7 +7097,7 @@ document.addEventListener('DOMContentLoaded', function() {
    こちらの実装は配列のインデックスを3000ms後に出力することを期待しています。
    ```js
    const arr = [10, 12, 15, 21];
    for (var i = 0; i < arr.length; i++) {
    for (const i = 0; i < arr.length; i++) {
    setTimeout(function() {
    console.log('The index of this number is: ' + i);
    }, 3000);
    @@ -7124,7 +7124,7 @@ for (var i = 0; i < arr.length; i++) {

    //変数iをそれぞれのfunctionに渡す
    const arr = [10, 12, 15, 21];
    for (var i = 0; i < arr.length; i++) {
    for (const i = 0; i < arr.length; i++) {
    // pass in the variable i so that each function
    // has access to the correct index
    setTimeout(function(i_local) {
    @@ -7261,7 +7261,7 @@ function add (x, y){
    return x + y;
    }
    function addAndLog(x, y){
    var result = add(x, y);
    const result = add(x, y);
    console.log(`Result:${result}`);
    return result;
    }
    @@ -7294,17 +7294,17 @@ function subtract(x, y){
    //HigherOrderFunction
    function logAndReturn(func) {
    return function(){
    var args = Array.prototype.slice.call(arguments);//返した関数の引数を配列にする
    var result = func.apply(null, args);//渡された関数に引数を渡し実行する
    const args = Array.prototype.slice.call(arguments);//返した関数の引数を配列にする
    const result = func.apply(null, args);//渡された関数に引数を渡し実行する
    console.log(`Result:${result}`);
    return result;
    }
    }

    var addAndLog = logAndReturn(add);
    const addAndLog = logAndReturn(add);
    addAndLog(4, 4);
    //'Result:8'
    var subtractAndLog = logAndReturn(subtract);
    const subtractAndLog = logAndReturn(subtract);
    subtractAndLog(4, 3);
    //'Result:1'
    ```
    @@ -7323,7 +7323,7 @@ console.log(a)


    //spread operatorが使えない環境下で
    var unique = Array.from(new Set([1,2,2,3,3,3,4,5])); // [1,2,3,4,5]
    const unique = Array.from(new Set([1,2,2,3,3,3,4,5])); // [1,2,3,4,5]

    ```
    @@ -7369,10 +7369,10 @@ console.log(['foo'])を実行し、
    Math.max(12, 45, 78) //returns 78

    //組み込み関数と一緒に使用する
    var max = Math.max.apply(null, [12, 45, 92, 78, 4]);//returns 92
    const max = Math.max.apply(null, [12, 45, 92, 78, 4]);//returns 92

    //e.g
    var array = [10, 20, 30];
    const array = [10, 20, 30];
    function average(){
    console.log.apply(console, arguments)
    }
    @@ -7396,7 +7396,7 @@ average(...array);//違う方法で
    function foo(x) {
    if (x > 10) return x + 1;

    var y = x / 2;
    const y = x / 2;

    if (y > 3) {
    if (x % 2 == 0) return x;
    @@ -7568,7 +7568,7 @@ console.log(denseKeys); // [0, 1, 2]//抜けを無視しない //要素は数
    こちら
    ```js
    (function() {
    var a = b = 5;
    const a = b = 5;
    })();

    console.log(b);
    @@ -7578,7 +7578,7 @@ bは何を出力しますか?
    ```js
    (function() {
    var a = b = 5;
    const a = b = 5;
    })();

    console.log(b);
    @@ -7597,7 +7597,7 @@ console.log(b);//Uncaught ReferenceError: b is not defined
    その場合明示的にしなくてはいけません。
    (function() {
    'use strict';
    var a = window.b = 5;
    const a = window.b = 5;
    })();

    console.log(b);
    @@ -7610,13 +7610,13 @@ console.log(b);
    こちら
    ```js
    var f = function g(){ return 23; };
    const f = function g(){ return 23; };
    typeof g();
    ```
    は何を返しますか??
    ```js
    var f = function g(){ return 23; };
    const f = function g(){ return 23; };
    typeof g();
    //Uncaught ReferenceError: g is not defined

    @@ -7638,9 +7638,9 @@ Stringオブジェクト上に整数値を受け取ってその数だけrepeat
    ```js
    String.prototype.repeatify = String.prototype.repeatify || function(times) {
    var str = '';
    const str = '';

    for (var i = 0; i < times; i++) {
    for (const i = 0; i < times; i++) {
    str += this;
    }

    @@ -7656,7 +7656,7 @@ function test() {
    console.log(a);
    console.log(foo());

    var a = 1;
    const a = 1;
    function foo() {
    return 2;
    }
    @@ -7677,7 +7677,7 @@ test();

    //問題のコードは下記と同じです
    function test() {
    var a;
    const a;
    function foo() {
    return 2;
    }
    @@ -7694,8 +7694,8 @@ test();
    下記コードは
    ```js
    var fullname = 'John Doe';
    var obj = {
    const fullname = 'John Doe';
    const obj = {
    fullname: 'Colin Ihrig',
    prop: {
    fullname: 'Aurelio De Rosa',
    @@ -7707,7 +7707,7 @@ var obj = {

    console.log(obj.prop.getFullname());

    var test = obj.prop.getFullname;
    const test = obj.prop.getFullname;

    console.log(test());

    @@ -7760,7 +7760,7 @@ logStuff({name: 'morita', job: engineer}, log);
    objはlogStuffの中でString型かObject型かチェックしてください。
    ```js
    var arr = [];
    const arr = [];
    function log(obj){
    if (typeof obj === 'string'){
    console.log(obj);
    @@ -7787,7 +7787,7 @@ logStuff({name: 'morita', job: 'engineer'}, log);
    こちらの
    ```js
    var clientData = {
    const clientData = {
    id: 094545,
    fullName: "Not Set",
    setUserName: function (firstName, lastName) {
    @@ -7806,7 +7806,7 @@ console.log(clientData.fullName)
    渡した値がfullNameにセットされて出力するようにしてください。
    ```js
    var clientData = {
    const clientData = {
    id: 094545,
    fullName: "Not Set",
    setUserName: function (firstName, lastName) {
    @@ -7825,7 +7825,7 @@ clientData.fullName
    こちら
    ```js
    var greet = function(greeting, name){
    const greet = function(greeting, name){
    console.log(greeting, name);
    }
    greet('Hello', 'kenji')
    @@ -7837,12 +7837,12 @@ greetをCurry化してgreetHello('kenji')を実行すると
    ```js
    var greetCurried = function(greeting){
    const greetCurried = function(greeting){
    return function(name){
    console.log(`${greeting} ${name}`)
    }
    }
    var greetHello = greetCurried('Hello')
    const greetHello = greetCurried('Hello')
    greetHello('kenji')
    //Hello kenji

    @@ -7852,7 +7852,7 @@ greetHello('kenji')
    こちら
    ```js
    var greetAwkwardly = greetDeeplyCurried("Hello")("...")("?");
    const greetAwkwardly = greetDeeplyCurried("Hello")("...")("?");
    greetAwkwardly("kenji");
    ```
    を実行した際に
    @@ -7863,7 +7863,7 @@ greetAwkwardly("kenji");
    が出力されるようにgreetDeeplyCurriedを実装してください
    ```
    var greetDeeplyCurried = function(greeting){
    const greetDeeplyCurried = function(greeting){
    return function(spread){
    return function(empasis){
    return function(name){
    @@ -7872,7 +7872,7 @@ var greetDeeplyCurried = function(greeting){
    }
    }
    }
    var greetAwkwardly = greetDeeplyCurried('Hello')('...')('?');
    const greetAwkwardly = greetDeeplyCurried('Hello')('...')('?');
    greetAwkwardly('kenji')
    //Hello...kenji?
    ```
    @@ -7981,7 +7981,7 @@ f.hasOwnProperty('name') //自身にnameをもつ //2


    //Array
    var arry = [];
    const arry = [];
    arry.__proto__ === Array.prototype
    //true
    arry.__proto__ === [].__proto__
    @@ -8695,7 +8695,7 @@ Math.pow(2, 4)
    **問題380**
    reducerを使って`[{id: 1, name: 'kenji'}]``{1: {name: 'kenji'}}` にしてください
    reduceを使って`[{id: 1, name: 'kenji'}]``{1: {name: 'kenji'}}` にしてください
    ```js
    [{id: 1, name: 'kenji'}].reduce((a, c)=> (a[c.id] = c) && a, {})
    @@ -8829,7 +8829,7 @@ function loggingDecorator(callback){
    }
    }

    var wrapped = loggingDecorator(dosomthing)
    const wrapped = loggingDecorator(dosomthing)
    wrapped("kenji")
    ```
    @@ -8879,6 +8879,24 @@ ins.sum(1, 2);
    [codeSandbox](https://codesandbox.io/s/decorator-x-typescript-x-react-hm8rj?file=/src/index.tsx)
    **問題386**
    数値を渡すと、その数値だけlengthを持つ配列で、且つその配列要素はそれぞれ1~999迄のランダムな整数である関数を作ってください eg: 5 -> [342, 920, 888, 292,129]
    ```js

    function generateNumber(num){
    const arr = Array.from({length: num}, ((_, i) => i))
    return arr.map(() => {
    return Math.floor(Math.random() * 1000)
    })
    }

    console.log(generateNumber(4)) // [342, 920, 888, 292,129] or some

    ```
    **WIP**
    //問題文をわかりやすくする
  6. kenmori revised this gist Jan 30, 2021. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -2,8 +2,6 @@
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2017/06/image3-1024x755.jpeg)


    ![visitors](https://visitor-badge.glitch.me/badge?page_id=page.id)

    **更新情報**

    ```
  7. kenmori revised this gist Jan 30, 2021. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2017/06/image3-1024x755.jpeg)


    ![visitors](https://visitor-badge.glitch.me/badge?page_id=page.id)

    **更新情報**

    ```
  8. kenmori revised this gist Jun 6, 2020. 1 changed file with 165 additions and 18 deletions.
    183 changes: 165 additions & 18 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,8 @@
    **更新情報**

    ```
    ・Decoratorsに関する問題を追加(2020/6/6)
    ・リンクを追加(2020/5/30)
    ・問題を追加(2020/4/18)
    ・表記揺れを整理(2020/1/13)
    ・TypeScript問題集のリンク追加(2019/7/13)
    @@ -15,7 +17,7 @@
    ```


    こちらは[よしもと芸人もりたけんじ](https://kenjimorita.jp/aboutme/)が自身のテストとして作ったJavaScript練習問題集です。
    こちらは[よしもと芸人もりたけんじ](https://kenjimorita.jp/aboutme/)が自身のテストとして作ったJavaScript練習問題集です。([TypeScript練習問題はこちら](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662))

    [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/bukotsunikki.svg?style=social&label=Follow%20%40bukotsunikki)](https://twitter.com/bukotsunikki)

    @@ -28,7 +30,7 @@
    ※答えはあくまで1つの記述です。

    ※ECMAScript2015の観点からは非奨励な書き方も載せています。(varやfor-in、破壊的メソッドの使用など)、
    環境に因って使用せざるを得ないなどがその理由です。
    環境に因って使用せざるを得ないなどがその理由です。(また、varの場合、コンソールログ上でそのままコピペ、再定義されているエラーを出させないというのもあります)
    また以下に示す問題の答えがあなたの考えた答えより冗長な書き方かもしれません。
    適宜置き換えていただけたらと思います。
    「答え」より端的な書き方、違うメソッド使用で解決できるなら「それが答え」です。
    @@ -1165,7 +1167,7 @@ console.log(array2);
    function isBigEnough(ele, ind, arry){
    return (ele >= 10);
    };
    var passed = [12, 5, 8, 130, 44].every(isBigEnough);
    const passed = [12, 5, 8, 130, 44].every(isBigEnough);
    passed //false

    ```
    @@ -1180,9 +1182,9 @@ passed //false
    の'two'の値を取得してください
    ```js
    var fafa = [['one', 'info@fa'],['two', 'send@fafa'],['three', 'hoso@fafa']
    const fafa = [['one', 'info@fa'],['two', 'send@fafa'],['three', 'hoso@fafa']
    ];
    var map = new Map(fafa);
    const map = new Map(fafa);
    map.get('two');
    //'send@fafa'

    @@ -1192,9 +1194,9 @@ map.get('two');
    問49の変数fafaにインデックス3番目の要素として['four',fafa@eee]の配列を追加してください
    ```js
    var fafa = [['one', 'info@fa'],['two', 'send@fafa'],['three', 'hoso@fafa']
    const fafa = [['one', 'info@fa'],['two', 'send@fafa'],['three', 'hoso@fafa']
    ];
    var map = new Map(fafa);
    const map = new Map(fafa);
    map.set('four', 'fafa@eee');
    ```
    @@ -1268,10 +1270,10 @@ isImport
    「」の中に「ヤッホー!」の文字列が1回以上続く場合にのみマッチする正規表現を書いてください。(!が英単語を構成する文字以外の場合はどうか、また「ヤッホー!」が2回以上3回以下にマッチにはどう書きますか)
    ```js
    var str = '「ヤッホー!ヤッホー!」'; /「(ヤッホー!)+/.exec(str); //['「ヤッホー!ヤッホー!」', 'ヤッホー!']
    const str = '「ヤッホー!ヤッホー!」'; /「(ヤッホー!)+/.exec(str); //['「ヤッホー!ヤッホー!」', 'ヤッホー!']

    //メタ文字
    var str = '「ヤッホー?ヤッホー@」';
    const str = '「ヤッホー?ヤッホー@」';
    /「(ヤッホー\W)+/.exec(str);
    ['「ヤッホー?ヤッホー@」', 'ヤッホー@']
    ```
    @@ -1285,12 +1287,12 @@ var str = '「ヤッホー?ヤッホー@」';
    ```js
    //文中に使えるかどうか
    //
    var str = '彼はありがとうと言った';
    const str = '彼はありがとうと言った';
    /彼は(ありがとう|こんにちは|さようなら)と言った/.exec(str);
    //['彼はありがとうと言った', 'ありがとう']

    //
    var str = '彼はありがとうと言った';
    const str = '彼はありがとうと言った';
    /彼はありがとう|こんにちは|さようならと言った/.exec(str);
    //['彼はありがとう']
    ```
    @@ -1299,7 +1301,7 @@ var str = '彼はありがとうと言った';
    「When」、「Where」、「Who」、「What」、「Why」、「How」の単語のみにマッチする正規表現を書きなさい
    ```js
    var str = 'How';
    const str = 'How';
    /Wh(en|ere|o|at|y|)|How/.exec(str);
    ```
    @@ -1385,7 +1387,7 @@ if (undefined == null){
    関数iiを実行すると返り値で関数を受け取り、その関数に引数'home'を渡し実行すると'my home'と返ってくるクロージャーを作ってください
    ```js
    var ii = function(){
    const ii = function(){
    var pp = 'my ';
    return function(value){
    console.log(pp + value);
    @@ -1400,8 +1402,8 @@ kk('home');
    今の時間、何時何分何秒を表してください
    ```js
    var now = new Date();
    var nowtime = '' + now.getHours() + '' + now.getMinutes() + '' + now.getSeconds() + '';
    const now = new Date();
    const nowtime = '' + now.getHours() + '' + now.getMinutes() + '' + now.getSeconds() + '';
    nowtime
    //'今23時49分56秒'
    ```
    @@ -8715,21 +8717,168 @@ reducerを使って、 `[{id: 1, name: 'kenji'}]` を `{1: {name: 'kenji'}}` に
    **問題382**
    `const res = {user: {name: 'kenji'}}``res.user``null`になりうることがある(`{user: null}`)。 `name`の値が欲しい時、 `null`の場合は`undefined``name`がある場合はその値を下記のように `const name = res.user && res.user.name` ではなく、 端的に(`optional chain`。オプショナルチェーンで)書いてください
    ```js

    const a = res.user?.name // undefined or "kenji"。 エラーにはならない

    // optional chain
    // ?の左がnullになり得る場合、もしnull or undefinedだったら.(ドットアクセス)でエラーにせず、undefinedを返し、そうでない場合はその先を返すというものです
    // つまり res.user == null ? undefined : res.user.name と res.user?.nameは同じです。端的に書けることがわかります
    ```
    **問題383**
    下記
    ```js
    const a = 0
    const b = false
    const c = undefined
    const d = null
    ```
    のような変数がある`null``undefined`の場合は文字列 `"null or undefined"`を返し、そうでない場合はその値を返す 関数isNullishを実装してください
    また、`Nullish coalescing Operator(ヌリッシュコアレスオペレーター)`とはどんなものですか?
    ```js
    const a = 0
    const b = false
    const c = undefined
    const d = null
    const isNullish = (value) => value ?? "null or undefined"
    isNullish(a) // 0
    isNullish(b) // false
    isNullish(c) // "null or undefined"
    isNullish(d) // "null or undefined"

    // また、Nullish coalescing Operator(ヌリッシュコアレシングオペレーター)とはどんなものですか?
    // nullish coalescing opearator は もし左がnull か undefinedなら 右 を返す || の代替です
    ```
    **問題384**
    ECMASCript2020で追加されたglobalThisとはなんですか?
    ```js
    ブラウザがもつグローバルオブジェクトである`window`Node.jsのグローバルオブジェクト`global`はJavaScript実行環境が違うため分けられていた。
    `globalThis`はブラウザ、Node.jsがもつ共通のグローバルオブジェクトです

    // use browser
    // open console.log and then
    // globalThis

    // use node with lts version
    // node -v
    // v12.16.2
    // > node
    // Welcome to Node.js v12.16.2.
    // Type ".help" for more information.
    // > globalThis
    // Object [global] {
    // global: [Circular],
    // clearInterval: [Function: clearInterval],
    // clearTimeout: [Function: clearTimeout],
    // setInterval: [Function: setInterval],
    // setTimeout: [Function: setTimeout] {
    // [Symbol(nodejs.util.promisify.custom)]: [Function]
    // },
    // queueMicrotask: [Function: queueMicrotask],
    // clearImmediate: [Function: clearImmediate],
    // setImmediate: [Function: setImmediate] {
    // [Symbol(nodejs.util.promisify.custom)]: [Function]
    // }
    // }
    ```
    **問題385**
    こちらの関数
    ```js
    function dosomthing(name){
    console.log("Hello " + name)
    }
    ```
    `dosomthing("kenji")`実行すると "Hello kenji"と出力されます。
    これを`dosomthing`の関数の中身を変えずに
    ```
    start
    Hello kenji
    finish
    ```
    `Hello kenji`の前と後に`start`, `finish`と出力されるようにしてください
    ```js
    function dosomthing(name){
    console.log("Hello " + name)
    }

    function loggingDecorator(callback){
    return function(){
    console.log("starting");
    const result = callback.apply(this, arguments);
    console.log("Finished");
    return result
    }
    }

    var wrapped = loggingDecorator(dosomthing)
    wrapped("kenji")
    ```
    **問題386**
    下記のように
    ```js
    class Example {
    @log
    sum(a, b){
    return a + b
    }
    }
    const e = new Example();
    e.sum(1, 2)
    ```
    でsumに対するlog(subに渡された引数)出力される@logz(Decorators)を作ってください
    ```js

    function log(_target, _name, descriptor) {
    const original = descriptor.value; // decorateしている関数
    if (typeof original === "function") {
    descriptor.value = function(...arg) {
    console.log("arguments:", `${arg}`);
    try {
    const result = original.apply(this, arg);
    return result;
    } catch (e) {
    console.log(`Error:${e}`);
    throw e;
    }
    };
    }
    return descriptor;
    }
    class Example {
    @log
    sum(a, b) {
    return a + b;
    }
    }
    const ins = new Example();
    ins.sum(1, 2);
    ```
    [codeSandbox](https://codesandbox.io/s/decorator-x-typescript-x-react-hm8rj?file=/src/index.tsx)
    **WIP**
    //問題文をわかりやすくする
    @@ -8762,9 +8911,6 @@ fun(1)
    //1
    ```
    ```js

    //下記の関数
    @@ -8880,4 +9026,5 @@ https://ponyfoo.com/articles/es6-array-extensions-in-depth
    https://speakerdeck.com/wakamsha/sore-motutosumatonishu-keruyo-javascript-kodowomotutoduan-ku-motutosinpurunishu-ku-tips-4xuan
    https://javascript.info/js
    https://davidwalsh.name/javascript-tricks
    https://www.sitepoint.com/javascript-decorators-what-they-are/
    </details>
  9. kenmori revised this gist Apr 17, 2020. No changes.
  10. kenmori revised this gist Apr 17, 2020. No changes.
  11. kenmori revised this gist Apr 17, 2020. No changes.
  12. kenmori revised this gist Apr 17, 2020. No changes.
  13. kenmori revised this gist Apr 17, 2020. 1 changed file with 13 additions and 2 deletions.
    15 changes: 13 additions & 2 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,11 @@
    # JavaScript練習問題集
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2017/06/image3-1024x755.jpeg)


    **更新情報**

    ```
    ・問題を追加(2020/4/18)
    ・表記揺れを整理(2020/1/13)
    ・TypeScript問題集のリンク追加(2019/7/13)
    ・問題を追加(2019/4/30) 平成最終日
    @@ -15,8 +17,7 @@

    こちらは[よしもと芸人もりたけんじ](https://kenjimorita.jp/aboutme/)が自身のテストとして作ったJavaScript練習問題集です。


    [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/bukotsunikki.svg?style=social&label=Follow%20%40bukotsunikki)](https://twitter.com/bukotsunikki)
    [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/bukotsunikki.svg?style=social&label=Follow%20%40bukotsunikki)](https://twitter.com/bukotsunikki)

    **前提**

    @@ -8692,14 +8693,24 @@ Math.pow(2, 4)
    **問題380**
    reducerを使って、 `[{id: 1, name: 'kenji'}]``{1: {name: 'kenji'}}` にしてください
    ```js
    [{id: 1, name: 'kenji'}].reduce((a, c)=> (a[c.id] = c) && a, {})
    ```
    **問題381**
    `[{1: {name: "kenji"}}, {2: {name: "rika"}}]` を reduceを使って `[{name: "kenji"},{name: "rika"}]` にしてください
    ```js

    // 一例)
    [{1: {name: "kenji"}}, {2: {name: "rika"}}].reduce((a, c) => {
    return [...a, ...Object.values(c)]
    }, [])

    ```
    **問題382**
  14. kenmori revised this gist Feb 8, 2020. No changes.
  15. kenmori revised this gist Feb 8, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,9 @@

    こちらは[よしもと芸人もりたけんじ](https://kenjimorita.jp/aboutme/)が自身のテストとして作ったJavaScript練習問題集です。


    [![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/bukotsunikki.svg?style=social&label=Follow%20%40bukotsunikki)](https://twitter.com/bukotsunikki)

    **前提**

    ※この問題集はChrome最新版のコンソール、[Google Chrome Canary](https://www.google.co.jp/chrome/browser/canary.html)のコンソールか、[JS Bin](https://jsbin.com/yenaderite/edit?js,console)などや[babel](http://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Ces2015-loose%2Ces2016%2Ces2017%2Clatest%2Creact%2Cstage-2&experimental=false&loose=false&spec=false&code=%5B1%2C2%2C3%5D.map(n%20%3D%3E%20n%20%2B%201)%3B&playground=true)、ECMAScript2015,2016,2017,2018,2019が使える環境で試されることを想定しています。
  16. kenmori revised this gist Jan 12, 2020. No changes.
  17. kenmori revised this gist Jan 12, 2020. 1 changed file with 252 additions and 138 deletions.
    390 changes: 252 additions & 138 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,12 @@
    # JavaScript練習問題集
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2019/04/de7d487a25d201f28ecd9e9cdaf27c9c.png)
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2017/06/image3-1024x755.jpeg)

    **更新情報**
    *[TypeScript Practice is here!!](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662)を追加

    ```
    ・表記揺れを整理(2020/1/13)
    ・TypeScript問題集のリンク追加(2019/7/13)
    ・問題を追加、画像を変更(2019/4/30)平成最終日
    ・問題を追加(2019/4/30) 平成最終日
    ・問題を追加(2019/4/16)
    ・問題を追加(2018/11/26)
    ・問題9の誤字を修正(2018/5/22)
    @@ -43,7 +43,7 @@

    [GitHub](https://github.com/kenmori)

    ※English [here](https://github.com/kenmori/javascript/blob/master/JavaScriptPractice.md)
    ※English [here](https://github.com/kenmori/javascript/blob/master/JavaScriptPractice)


    ## JavaScript問題集
    @@ -69,8 +69,10 @@ c //{a: 'a', b: 'b'}
    //・prototypeに定義し直したい場合、Object.getOwnPropertyDescriptorとObject.definePropertyを使う
    //・プロパティが書き込み不可の場合TypeErrorが発生。targetオブジェクトは変更されない
    //・Object.assignはsources値がnull、undefinedの場合例外を投げない
    ```

    別解
    const c = {...a, ...b}
    ```
    **問2**

    ```js
    @@ -1194,6 +1196,7 @@ map.set('four', 'fafa@eee');
    </details>
    <details><summary>問51〜問100</summary>
    **問51**
    問50の変数fafa内にある要素を出力してください
    @@ -5120,6 +5123,7 @@ pop、push、reverse、shift、sort、splice、unshilft

    </details>
    <details><summary>251〜問300</summary>

    **251**

    ```var arr = ['one', 'two', 'three']```においてarrを不変オブジェクトに変更してください。
    @@ -5156,13 +5160,15 @@ console.log(obj3.b.a)
    **252**

    このようなobjがあります。

    ```js
    var obj = {
    'prop1': 'value1',
    'prop2': 'value2',
    'prop3': 'value3'
    }
    ```

    JSON.stringifyを使って

    ```
    @@ -5212,6 +5218,7 @@ str

    **253**
    this呼び出しを4つとそれぞれのthis参照の参照先オブジェクトを答えてください

    ```js
    ・コンストラクタ呼び出し・・・コンストラクタが生成したオブジェクト
    ・メソッド呼び出し・・・レシーバオブジェクト(ドット演算子、ブラケット演算子でオブジェクトのメソッドを読んだとき、演算子の左辺に指定したオブジェクト)
    @@ -5223,8 +5230,6 @@ e.g const obj = {add : function(){some}};
    ・それ以外の呼び出し ・・・グローバルオブジェクト
    //this参照はコードのコンテキストに応じて自動的に参照先オブジェクトが変わる特別なもの
    ```

    **254**
    @@ -5238,6 +5243,7 @@ console.log(map); // Map { foo: 'bar', baz: 42 }
    ```

    **255**

    ```js
    var Emiiter = {
    callbacks : [],
    @@ -5286,6 +5292,7 @@ if(color){
    }
    }
    ```

    これをswitch文に変えたのがこちらですが、

    ```js
    @@ -5305,7 +5312,7 @@ switch (color){
    ```
    デバッグしづらいのといくつかの評価をしなくてはならなくなった際につらくなります。
    see: https://toddmotto.com/deprecating-the-switch-statement-for-object-literals/
    see: [https://toddmotto.com/deprecating-the-switch-statement-for-object-literals/](https://toddmotto.com/deprecating-the-switch-statement-for-object-literals/)
    ```js
    switch(true) {
    @@ -5347,9 +5354,6 @@ if (color in colorObj) {
    //black
    ```
    **問257**
    こちら['a','b','c’]をこちら{0: 'a’, 1: 'b’, 2: 'c'}のようにしてください
    @@ -5370,6 +5374,7 @@ toObject(arry);
    **問258**
    こちら
    ```js
    let html = '';
    const count = 10;
    @@ -5379,6 +5384,7 @@ for(var i = 0;i < count; i++){
    document.querySelector('#mngb').innerHtml = html;
    'hai!!hai!!hai!!hai!!hai!!hai!!hai!!hai!!hai!!hai!!'
    ```
    をより高速な書き方をしてください
    ```js
    @@ -5396,6 +5402,7 @@ document.querySelector('#mngb').innerHtml = html.join('');
    **問259**
    このような関数があります
    ```js
    function iterateTimerOver(){
    const length = 100;
    @@ -5404,6 +5411,7 @@ function iterateTimerOver(){
    }
    }
    ```
    Timerはグローバル関数です。より高速にしてください。
    ```js
    @@ -5438,9 +5446,11 @@ name
    **問260**
    こちら
    ```js
    const myObject = {1: ['e', 'ee', 'eee'], 2: ['f', 'ff','fff']};
    ```
    多次元配列にしてください
    期待する結果:[[‘e’,’ee’,’eee’],[‘f’,’ff’, ‘fff’]];
    @@ -5500,12 +5510,14 @@ obj
    **問261**
    こちら
    ```js
    const arr = [
    { key: 'foo', val: 'bar' },
    { key: 'hello', val: 'world' }
    ];
    ```
    をMapオブジェクトにしてください
    期待する結果:{'foo' => 'bar', 'hello' => 'world'}
    @@ -5654,6 +5666,7 @@ try {
    **問268**
    こちらの
    ```js
    const foo = (name, callback) => {
    setTimeout(() => {
    @@ -5672,45 +5685,40 @@ foo('a', (a) => {
    // b
    // c
    ```
    ネストされた読みにくい処理記述をgenerator関数を使って記述し直してください。
    ```js
    const foo = (name, callback) => {
    setTimeout(() => {
    callback(name);
    }, 100);
    setTimeout(() => {
    callback(name);
    }, 100);
    };

    const curry = (method, ...args) => {
    return (callback) => {
    args.push(callback);
    return method.apply({}, args);
    };
    return (callback) => {
    args.push(callback);
    return method.apply({}, args);
    };
    };

    const controller = (generator) => {
    const iterator = generator();

    const advancer = (response) => {
    var state;

    state = iterator.next(response);

    if (!state.done) {
    state.value(advancer);
    }
    }

    advancer();
    const iterator = generator();
    const advancer = (response) => {
    var state;
    state = iterator.next(response);
    if (!state.done) {
    state.value(advancer);
    }
    }
    advancer();
    };

    controller(function* () {
    const a = yield curry(foo, 'a');
    const b = yield curry(foo, 'b');
    const c = yield curry(foo, 'c');
    console.log(a, b, c);
    const a = yield curry(foo, 'a');
    const b = yield curry(foo, 'b');
    const c = yield curry(foo, 'c');
    console.log(a, b, c);
    });

    // a
    // b
    // c
    @@ -5728,20 +5736,20 @@ controller(function* () {
    ```js
    function *foo() {
    var z = yield 3;
    var w = yield 4;
    console.log( 'z: ' + z + ', w: ' + w );
    const z = yield 3;
    const w = yield 4;
    console.log( 'z: ' + z + ', w: ' + w );
    }

    function *bar() {
    var x = yield 1;
    var y = yield 2;
    yield *foo(); // `yield*` delegates iteration control to `foo()`
    var v = yield 5;
    console.log( 'x: ' + x + ', y: ' + y + ', v: ' + v );
    const x = yield 1;
    const y = yield 2;
    yield *foo(); // `yield*` delegates iteration control to `foo()`
    const v = yield 5;
    console.log( 'x: ' + x + ', y: ' + y + ', v: ' + v );
    }

    var it = bar();
    const it = bar();

    it.next(); // { value:1, done:false }
    it.next( 'X' ); // { value:2, done:false }
    @@ -5779,37 +5787,40 @@ for-ofに渡すと1~10までの数値を返すitarableなオブジェクトを
    ```js
    var obj = {}; // イテラブルなオブジェクト
    obj[Symbol.iterator] = function(){//イテレータを返す関数を代入
    var iterator = {}; // イテレータ
    var num = 1;
    iterator.next = function(){//next実行してリザルトを返す関数を代入
    var iteratorResult = (num <= 10)
    ? { value: num++, done: false }
    : { value: undefined, done: true };
    return iteratorResult; // イテレータリザルトを返す
    };
    return iterator;//イテレータを返す
    var iterator = {}; // イテレータ
    var num = 1;
    iterator.next = function(){//next実行してリザルトを返す関数を代入
    var iteratorResult = (num <= 10)
    ? { value: num++, done: false }
    : { value: undefined, done: true };
    return iteratorResult; // イテレータリザルトを返す
    };
    return iterator;//イテレータを返す
    };
    ```
    **問272**
    こちらの
    ```js
    function* g(){
    const num = yield 30
    const num2 = yield 1 + num
    yield 2 + num2
    yield num + num2
    const num = yield 30

    const num2 = yield 1 + num
    yield 2 + num2
    yield num + num2
    }
    ```
    iteratorのnextメソッドに1を渡してdoneがtrueになるまで```iterator.next(1).value```のように実行していくとそれぞれ何を返すか答えてください。
    ```js
    function* g(){
    const num = yield 30//numは2回目next()実行時の仮引数になる
    const num2 = yield 1 + num//num2は3回目next()実行時の仮引数になる
    yield 2 + num2
    yield num + num2
    const num = yield 30//numは2回目next()実行時の仮引数になる
    const num2 = yield 1 + num//num2は3回目next()実行時の仮引数になる
    yield 2 + num2
    yield num + num2
    }
    const iterator = g();
    iterator.next(1).value
    @@ -5826,7 +5837,8 @@ iterator.next(1).value
    **問273**
    こちらのfooを
    こちらの`foo`
    ```js
    function* foo(x) {
    var y = 2 * (yield (x + 1));
    @@ -5838,6 +5850,7 @@ it.next();//1
    it.next(12);//2
    it.next(13);//3
    ```
    上の1,2,3の箇所のように実行したら出力される値をそれぞれ教えてください
    ```js
    @@ -5920,12 +5933,14 @@ for-in loop
    **問278**
    こちらを実行すると
    ```js
    const sym = Symbol('desc');
    const str1 = '' + sym;
    str1
    //???
    ```
    どうなりますか?
    ```
    @@ -5940,24 +5955,23 @@ const str2 = `${sym}`; //TypeError
    シンボルのユースケースをざっくり2つほど教えて下さい。
    ```js

    //1
    //unique property keys (ユニークなプロパティkey)
    //for-ofを通して使えるobject iterableを作ることができる
    const iterableObject = {
    [Symbol.iterator]() { // メソッドのキーとしてSymbolを使う
    const data = ['hello', 'world'];
    let index = 0;
    return {
    next() {
    if (index < data.length) {
    return { value: data[index++] };
    } else {
    return { done: true };
    }
    }
    };
    }
    [Symbol.iterator]() { // メソッドのキーとしてSymbolを使う
    const data = ['hello', 'world'];
    let index = 0;
    return {
    next() {
    if (index < data.length) {
    return { value: data[index++] };
    } else {
    return { done: true };
    }
    }
    };
    }
    }
    for (const x of iterableObject) {
    console.log(x);
    @@ -5981,25 +5995,26 @@ const COLOR_BLUE = Symbol('Blue');
    const COLOR_VIOLET = Symbol('Violet');

    function getComplement(color) {
    switch (color) {
    case COLOR_RED:
    return COLOR_GREEN;
    case COLOR_ORANGE:
    return COLOR_BLUE;
    case COLOR_YELLOW:
    return COLOR_VIOLET;
    case COLOR_GREEN:
    return COLOR_RED;
    case COLOR_BLUE:
    return COLOR_ORANGE;
    case COLOR_VIOLET:
    return COLOR_YELLOW;
    default:
    throw new Exception('Unknown color: '+color);
    }
    switch (color) {
    case COLOR_RED:
    return COLOR_GREEN;
    case COLOR_ORANGE:
    return COLOR_BLUE;
    case COLOR_YELLOW:
    return COLOR_VIOLET;
    case COLOR_GREEN:
    return COLOR_RED;
    case COLOR_BLUE:
    return COLOR_ORANGE;
    case COLOR_VIOLET:
    return COLOR_YELLOW;
    default:
    throw new Exception('Unknown color: '+color);
    }
    }

    ```
    **問280**
    こちらは
    @@ -6018,7 +6033,6 @@ TypeErrorをthrowするので、try/catchしているのだが、
    if...elseブロックを使える、Reflectを用いて同じ実装になるように修正してください
    ```js
    let target = {name: 'ken'}
    const isAble = Reflect.defineProperty(target, 'name', {value: 'fe'})
    @@ -6027,6 +6041,7 @@ if(isAble){
    } else {}

    ```
    **問281**
    こちらの
    @@ -6040,18 +6055,23 @@ Reflect.deletePropery(target, 'key')
    **問282**
    こちらはReflect.getを使って
    ```js
    var obj = {a : 1}
    Reflct.get(obj, "a")
    //1
    ```
    値を取得している。
    ```
    ```js
    obj["a"]
    //1
    ```
    との違いを教えてください
    ```
    ```js
    //objが非オブジェクトの際、ReflectはTypeErrorをthrowしますが、obj["a"]は
    //undefinedになります。実行時objの型が適切か気づくことができます。

    @@ -6106,6 +6126,7 @@ Reflect.apply(fun, ctx, [1,2,3])
    **問284**
    こちら
    ```js
    String.fromCharCode(104,101,108,108,111)
    "hello"
    @@ -6116,7 +6137,6 @@ String型の静的メソッドであるfromCharCodeは常にStringを伴って
    Number型を渡さなくてはいけない引数に配列を渡し、
    同じ出力になるようにしてください
    ```js
    Reflect.apply(String.fromCharCode, undefined, [104, 101, 108, 108, 111])
    //"hello"
    @@ -6191,9 +6211,11 @@ var obj = {
    **問288**
    このようながDOMがあります。
    ```
    ```html
    <span id='foo' class='bar baz'>foo</span>
    ```
    付与されたclass名が存在するだけ出力してください。
    期待する出力
    @@ -6223,13 +6245,14 @@ else
    el.className += ' ' + className;
    ```
    **問289**
    こちら
    ```
    ```html
    <span id='foo' class='bar baz'>foo</span>
    ```
    の中にbazがあることを真偽値で出力してください
    ```js
    @@ -6243,9 +6266,11 @@ foo.classList.contains('foo');
    **問290**
    こちら
    ```
    ```html
    <span id='foo' class='bar baz'>foo</span>
    ```
    にfafaというclass名を追加してbarを削除してください
    ```js
    @@ -6260,21 +6285,23 @@ foo.classList.remove('bar');
    **問291**
    こちら
    ```
    ```js
    $.getJSON('/my/url', function(data) {
    });
    ```
    Jqueryでgetしているが、ライブラリを使用しないのでJS記述してください。
    ```js
    //一例
    var request = new XMLHttpRequest();
    const request = new XMLHttpRequest();
    request.open('GET', '/my/url', true);

    request.onload = function() {
    if (request.status >= 200 && request.status < 400) {
    // Success!
    var data = JSON.parse(request.responseText);
    const data = JSON.parse(request.responseText);
    } else {
    // We reached our target server, but it returned an error
    }
    @@ -6293,13 +6320,12 @@ var data = { foo: 'abc', bar: 100 }
    期待する結果
    'foo=abc&bar=100'
    ```js
    var arr = [];
    let arr = [];
    Object.keys(data).forEach(function(el, ind){
    arr.push(encodeURIComponent(el) + "=" + encodeURIComponent(data[el]))
    })
    var str = arr.join("&")
    const str = arr.join("&")
    str
    //'foo=abc&bar=100'
    ```
    @@ -6324,6 +6350,7 @@ Array.prototype.forEach.call(elements, function(el, i){
    **問294**
    こちら
    ```js
    $(el).after(htmlString);//1

    @@ -6335,6 +6362,7 @@ $(el).next();//4

    $(el).parent();//5
    ```
    と同じ動きをJSで記述してください
    ```js
    @@ -6357,9 +6385,11 @@ el.parentNode
    **問295**
    こちら
    ```js
    $(el).hasClass(className);
    ```
    と同じ処理をJSで記述してください
    ```js
    @@ -6374,10 +6404,12 @@ if (el.classList){
    **問296**
    こちらの2つの処理
    ```js
    $(el).next();
    $(el).parent();
    ```
    と同じことをJSで記述してください
    ```js
    @@ -6389,10 +6421,12 @@ el.parentNode
    **問297**
    こちら
    ```js
    $(el).offset();
    //{top: 11, left:11}
    ```
    と同じ値を含むオブジェクトを取得できるようにJSで記述してください。
    ```js
    @@ -6409,6 +6443,7 @@ rect
    ```js
    $(el).remove();
    ```
    と同じ処理をするようにJSで記述してください。
    ```js
    @@ -6418,9 +6453,11 @@ el.parentNode.removeChild(el);
    **問299**
    こちら
    ```js
    $(el).removeClass(className);
    ```
    と同じ処理をするようにJSで記述してください。
    ```js
    @@ -6434,6 +6471,7 @@ if (el.classList) {
    **問300**
    こちら
    ```js
    $(el).attr('tabindex', 3);
    ```
    @@ -6442,11 +6480,14 @@ $(el).attr('tabindex', 3);
    ```js
    el.setAttribute('tabindex', 3);
    ```
    </details>
    <details><summary>問301〜問350</summary>
    **問301**
    こちら
    ```js
    $(el).toggleClass(className);
    ```
    @@ -6468,12 +6509,14 @@ if (el.classList) {
    }
    ```
    **問302***
    **問302**
    こちら
    ```js
    $.parseHTML(htmlString);
    ```
    と同じ処理をするようにJSで記述してください。
    @@ -6490,9 +6533,11 @@ parseHTML(htmlString);
    **問303**
    こちら
    ```js
    $(el).on(eventName, eventHandler);
    ```
    と同じ処理をするようにJSで記述してください。
    ```js
    @@ -6502,6 +6547,7 @@ el.addEventListener(eventName, eventHandler);
    **問304**
    こちらはDOMの解析とロードの条件で渡されたコールバック、fncが同期的に呼ばれるか非同期に呼ばれるか変わるコードです。
    ```js
    function onReady(fnc) {
    var readyState = document.readyState;
    @@ -6516,6 +6562,7 @@ onReady(function () {
    });
    console.log('Start');
    ```
    大雑把にいうと、body終了直前に書かれていた場合条件式trueの文が実行され同期的に、
    head内で書かれていた場合elseブロックが実行され非同期的に呼ばれます。
    なので'Start'が出力される順番が変わるのですが、
    @@ -6538,12 +6585,12 @@ head内で書かれていた場合elseブロックが実行され非同期的に

    //ex1 setTimeout
    function onReady(fnc) {
    var readyState = document.readyState;
    if (readyState === 'interactive' || readyState === 'complete') {
    setTimeout(fnc, 0);
    } else {
    window.addEventListener('DOMContentLoaded', fnc);
    }
    const readyState = document.readyState;
    if (readyState === 'interactive' || readyState === 'complete') {
    setTimeout(fnc, 0);
    } else {
    window.addEventListener('DOMContentLoaded', fnc);
    }
    }
    onReady(function () {
    console.log('DOMは解析とロード済み');
    @@ -6555,14 +6602,15 @@ console.log('Start');

    //ex2 Promise
    function onReady() {
    return new Promise(function(resolve, reject){
    var readyState = document.readyState;
    if (readyState === 'interactive' || readyState === 'complete') {
    resolve();
    } else {
    window.addEventListener('DOMContentLoaded', resolve);
    }
    })}
    return new Promise(function(resolve, reject){
    const readyState = document.readyState;
    if (readyState === 'interactive' || readyState === 'complete') {
    resolve();
    } else {
    window.addEventListener('DOMContentLoaded', resolve);
    }
    })
    }
    onReady().then(function(){
    console.log('DOMは解析とロード済み')
    })
    @@ -6590,21 +6638,22 @@ console.log('Start');
    最後のPromiseオブジェクトでそれらが連結された文字列を出力してください。
    ```js
    var initPromise = new Promise(function(resolve){
    const initPromise = new Promise(function(resolve){
    resolve('私は')
    })
    var lastName = function(sentence, lastname){
    const lastName = function(sentence, lastname){
    return sentence + '今日、'
    }
    var firstName = function(lastName){
    const firstName = function(lastName){
    return lastName + '運がいいです'
    }
    var comp = function(compName){
    const comp = function(compName){
    console.log(compName)
    }
    initPromise.then(lastName).then(firstName).then(comp);
    //私は今日、運がいいです
    ```
    **問307**
    Promseオブジェクト作成時にresolveに数値1を渡すコールバックを呼び出し、console出力され、
    @@ -6628,6 +6677,7 @@ promise1.then(function(val){
    **問308**
    Promiseオブジェクトを使ってGETメソッドリクエスト,list.jsonを取得してください。urlは`http://kenmori.jp/list.json`とする

    ```js
    function get(url) {
    return new Promise(function(resolve, reject) {
    @@ -6658,6 +6708,7 @@ get('list.json').then(function(res){
    **309**

    Promiseオブジェクトを使ってこちら

    ```js
    function say(callback, msg) {
    setTimeout(callback, msg);
    @@ -7965,7 +8016,9 @@ let b = new A('JavaScript');
    //JavaScriptはb上のプロパティcarを探し、見つからなければ上記2で作成されたb.__proto__(A.prototype)を参照し、A.prototypeにあるcarプロパティ値を返すためです。

    ```

    </details>

    <details><summary>問351〜問400</summary>

    **問351**
    @@ -8273,8 +8326,8 @@ why:
    参照がその参照を参照してその参照がさらにその参照をしてと繰り返されることです
    ```js
    var a = {};
    var b = {};
    let a = {};
    let b = {};
    a.child = b;
    b.child = a;
    を実行した場合
    @@ -8311,11 +8364,11 @@ JSON.stringify(value[, replacer, space])

    //[replacer](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)を設定します

    var obj = {
    let obj = {
    a: "foo",
    b: obj
    }
    var replacement = {"b":undefined}; //undefinedをいれてskipさせる
    let replacement = {"b":undefined}; //undefinedをいれてskipさせる
    JSON.stringify(obj,replacement));
    ```
    or
    @@ -8559,26 +8612,79 @@ str.split('').reverse().join('')
    **問題376**
    addという関数
    ```js
    add(a){
    return a + a
    }
    add(2) //4
    ```
    はaを引数に取りa + aの値を返す関数です。
    これを改善して、a関数に同じ値a(上記の場合`2`)が渡ったら以前と同じ値なら以前に計算された結果である(上記の場合`4`)の`cache`を返すようにしてください
    ```js

    function add (a){
    if(!add.cache){
    add.cache = {}
    console.log("cache create!")
    }
    if(!add.cache[a]){
    add.cache[a] = a + a;
    console.log("create value in cacche!")
    }
    return add.cache[a]
    }
    ```
    **問題377**
    数値 `-6.133``6.133` を正数値だけ取得してください。
    ```js
    let num = -6.133
    Math.trunc(num)
    // -6


    let num = 6.133
    Math.trunc(num)
    // 6
    ```
    **問題378**
    こちら2の4乗
    ```js
    Math.pow(2, 4)
    // 16
    ```
    と同じことをしてください
    ```js
    2 ** 4
    // 16
    //ECMAScript216の べき乗演算子**(Exponentiation Operator)
    ```
    **問題379**
    こちらの文字列
    ```js
    "パスワードは😄😄😄😄です".length
    // 16
    ```
    は16文字として処理されます
    絵文字1つを2とカウントしないようにしてください
    ```js
    [..."パスワードは😄😄😄😄です"].length
    // 12
    ```
    **問題380**
    @@ -8632,7 +8738,7 @@ function fn() {
    }
    };
    }
    var fun = fn()
    const fun = fn()
    //Generate cache
    fun(1)
    //Calculate and save to cache
    @@ -8647,7 +8753,7 @@ fun(1)
    ```js

    下記の関数
    //下記の関数

    function f(images, index, attributes){
    return {images: [ ...images.slice(0, index), {...images[index], ...attributes}, ...images.slice(index + 1)]}
    @@ -8664,7 +8770,7 @@ f(["eeee","ppp","lll"], 1, [1,2,3])
    ```js

    var object = {
    let object = {
    innerObject:{
    deepObject:{
    value:'Here am I'
    @@ -8680,7 +8786,7 @@ if(object && object.innerObject && object.innerObject.deepObject && object.inner
    このように退屈なif文にならないためのユーティリティ関数
    ```js
    var obj = {
    let obj = {
    innerObject: {
    deepObject: {
    value: 'Here am I'
    @@ -8693,7 +8799,7 @@ function hasOwnDeepProperty(obj, prop) {
    if (obj.hasOwnProperty(prop)) { // if this object already contains the property, we are done
    return true;
    }
    for (var p in obj) { // otherwise iterate on all the properties of this object
    for (let p in obj) { // otherwise iterate on all the properties of this object
    if (obj.hasOwnProperty(p) && // and as soon as you find the property you are looking for, return true
    hasOwnDeepProperty(obj[p], prop)) {
    return true;
    @@ -8706,6 +8812,14 @@ function hasOwnDeepProperty(obj, prop) {
    console.log(hasOwnDeepProperty(obj, 'value')); // true
    console.log(hasOwnDeepProperty(obj, 'another')); // false

    ```
    [付録] [Observable](https://tc39.github.io/proposal-observable/)
    ```js


    ```
  18. kenmori revised this gist Jul 13, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,10 @@
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2019/04/de7d487a25d201f28ecd9e9cdaf27c9c.png)

    **更新情報**
    *[TypeScript Practice is here!!](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662)を追加

    ```
    *[TypeScript Practice is here!!](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662)を追加
    TypeScript問題集のリンク追加(2019/7/13)
    ・問題を追加、画像を変更(2019/4/30)平成最終日
    ・問題を追加(2019/4/16)
    ・問題を追加(2018/11/26)
  19. kenmori revised this gist Jul 13, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    **更新情報**

    ```
    ・*[TypeScript Practice is here!!](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662)を追加
    ・問題を追加、画像を変更(2019/4/30)平成最終日
    ・問題を追加(2019/4/16)
    ・問題を追加(2018/11/26)
    @@ -43,7 +44,6 @@

    ※English [here](https://github.com/kenmori/javascript/blob/master/JavaScriptPractice.md)

    *[TypeScript Practice is here!!](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662)

    ## JavaScript問題集

  20. kenmori revised this gist Jul 6, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@

    ※English [here](https://github.com/kenmori/javascript/blob/master/JavaScriptPractice.md)

    *[TypeScript Practice](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662) is here!!
    *[TypeScript Practice is here!!](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662)

    ## JavaScript問題集

  21. kenmori revised this gist Jul 6, 2019. No changes.
  22. kenmori revised this gist Jul 6, 2019. No changes.
  23. kenmori revised this gist Jul 6, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -43,6 +43,8 @@

    ※English [here](https://github.com/kenmori/javascript/blob/master/JavaScriptPractice.md)

    *[TypeScript Practice](https://gist.github.com/kenmori/8cea4b82dd12ad31f565721c9c456662) is here!!

    ## JavaScript問題集

    <details><summary>問1〜問50</summary>
  24. kenmori revised this gist Apr 30, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    **更新情報**

    ```
    ・問題を追加(2019/4/30) 平成最終日
    ・問題を追加、画像を変更(2019/4/30)平成最終日
    ・問題を追加(2019/4/16)
    ・問題を追加(2018/11/26)
    ・問題9の誤字を修正(2018/5/22)
  25. kenmori revised this gist Apr 30, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # JavaScript練習問題集
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2017/06/image3-1024x755.jpeg)
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2019/04/de7d487a25d201f28ecd9e9cdaf27c9c.png)

    **更新情報**

  26. kenmori revised this gist Apr 30, 2019. 1 changed file with 384 additions and 98 deletions.
    482 changes: 384 additions & 98 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,39 @@
    ## JavaScript練習問題集
    # JavaScript練習問題集
    ![JavaScript](https://kenjimorita.jp/wp-content/uploads/2017/06/image3-1024x755.jpeg)

    **更新情報**

    ```
    ・WIP、問題357を作成(2018/11/30)
    ・問題358-368を追加(2018/11/25)
    ・問題を追加(2019/4/30) 平成最終日
    ・問題を追加(2019/4/16)
    ・問題を追加(2018/11/26)
    ・問題9の誤字を修正(2018/5/22)
    ```


    こちらは[よしもと芸人もりたけんじ](https://kenjimorita.jp/aboutme/)が自身のテストとして作ったJavaScript練習問題集です。

    #### こちらは[よしもと芸人もりたけんじ](https://kenjimorita.jp/aboutme/)が自身のテストとして作ったJavaScript練習問題集です。
    **前提**

    ※この問題集はChrome最新版のコンソール、[Google Chrome Canary](https://www.google.co.jp/chrome/browser/canary.html)のコンソールか、[JS Bin](https://jsbin.com/yenaderite/edit?js,console)などや[babel](http://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Ces2015-loose%2Ces2016%2Ces2017%2Clatest%2Creact%2Cstage-2&experimental=false&loose=false&spec=false&code=%5B1%2C2%2C3%5D.map(n%20%3D%3E%20n%20%2B%201)%3B&playground=true)、ECMAScript2015,2016,2017が使える環境で試されることを想定しています
    ※この問題集はChrome最新版のコンソール、[Google Chrome Canary](https://www.google.co.jp/chrome/browser/canary.html)のコンソールか、[JS Bin](https://jsbin.com/yenaderite/edit?js,console)などや[babel](http://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Ces2015-loose%2Ces2016%2Ces2017%2Clatest%2Creact%2Cstage-2&experimental=false&loose=false&spec=false&code=%5B1%2C2%2C3%5D.map(n%20%3D%3E%20n%20%2B%201)%3B&playground=true)、ECMAScript2015,2016,2017,2018,2019が使える環境で試されることを想定しています

    ※表記揺れは鋭意解消中
    ※表記揺れは鋭意解消中

    ※答えはあくまで1つの記述です。

    ※ECMAScript2015の観点からは非奨励な書き方も載せています(varやfor-in、破壊的メソッドの使用など)。
    適宜置き換えていただけたらと思います。「答え」より端的な書き方、違うメソッド使用で解決できるならそれが答えです。
    ※ECMAScript2015の観点からは非奨励な書き方も載せています。(varやfor-in、破壊的メソッドの使用など)、
    環境に因って使用せざるを得ないなどがその理由です。
    また以下に示す問題の答えがあなたの考えた答えより冗長な書き方かもしれません。
    適宜置き換えていただけたらと思います。
    「答え」より端的な書き方、違うメソッド使用で解決できるなら「それが答え」です。

    ※修正依頼は[こちら](https://omajimedesign.drift.com/omajimedesign)
    ・途中似ているような問題が出てくるかもしれませんが気にしないでください。

    *月一で更新予定
    ・答えが見えてしまっているのは都度操作させないためです

    *★を押していただけたら今後もやる気出ます。よろしくお願いします。
    ※・プルリク歓迎です。修正依頼は[こちら](https://omajimedesign.drift.com/omajimedesign)

    *★を押していただけたら今後もやる気出ます。よろしくお願いします。

    [blog/JavaScript](https://kenjimorita.jp/category/javascript/)

    @@ -37,20 +43,29 @@

    ※English [here](https://github.com/kenmori/javascript/blob/master/JavaScriptPractice.md)

    ## JavaScript問題集

    <details><summary>問1〜問50</summary>

    **問1**

    ```const a = {a: 'a'}``````const b = {b: 'b'}```
    ```const a = { a: 'a' }``````const b = { b: 'b' }```
    をマージした```c```
    を出力してください
    e.g```{a:'a',b:'b'}```
    e.g```{ a:'a', b:'b' }```

    ```js
    const a = {a: 'a'};
    const b = {b:'b'};
    const a = { a: 'a' };
    const b = { b:'b'};
    const c = Object.assign({}, a, b);
    c //{a: 'a', b: 'b'}

    //Object.assign(target, ...sources)
    //・戻り値はtargetオブジェクト
    //・sroucesオブジェクトの挙可能で自分が所有するプロパティのみtargetにコピーされる
    //・prototypeに定義し直したい場合、Object.getOwnPropertyDescriptorとObject.definePropertyを使う
    //・プロパティが書き込み不可の場合TypeErrorが発生。targetオブジェクトは変更されない
    //・Object.assignはsources値がnull、undefinedの場合例外を投げない
    ```

    **問2**
    @@ -68,7 +83,7 @@ const newArry = arry.slice(3,-1);

    **問3**

    const arry = ['a','b’] の要素をconsole出力してください e.g ```'a'``````'b'```
    ['a','b’] の要素をconsole出力してください e.g ```'a'``````'b'```

    ```js
    const arry = ['a','b'];
    @@ -81,20 +96,20 @@ arry.forEach(function(elem,i){

    **問4**

    ```const arry = ['a', 'b']```の各要素にindex値を足した文字列を出力してください```e.g 'a0'``````'b1'```
    ```['a', 'b']```の各要素にindex値を足した文字列を出力してください```e.g 'a0'``````'b1'```

    ```js
    const arry = ['a','b'];
    arry.forEach(function(key,i){
    console.log(key + i)
    arry.forEach(function(ele,i){
    console.log(ele + i)
    })
    //'a0'
    //'b1'
    ```

    **問5**

    ```const arry = [1,2]```と定義して配列かどうかを評価してください
    ```任意の変数名の[1,2]```を定義して配列かどうかを評価してください
    e.g true

    ```js
    @@ -134,7 +149,7 @@ if(x === undefined){
    ```js
    //1
    var x;
    let x;
    if (x === void 0) {
    }

    @@ -288,7 +303,7 @@ foo.bar
    **問11**
    ```js
    var arry =[
    let arry =[
    {id:1,name:'morita'},
    {id:2,name:'kenji'},
    {id:4,name:'uro'},
    @@ -328,15 +343,15 @@ arry.sort(function(a,b){
    **問12**
    ```var a, b;```の変数はデフォルトとしてaは5、bは7を持ち、aに1を代入してconsole出力してください。
    ``` a, b```の変数はデフォルトとしてaは5、bは7を持ち、aに1を代入してconsole出力してください。
    ```js
    var [a=5, b=7] = [1];
    const [a=5, b=7] = [1];
    console.log(a, b);
    //1 7

    //other
    var {a = 5, b = 7} = {a: 1}
    const {a = 5, b = 7} = {a: 1}
    ```
    @@ -345,13 +360,13 @@ var {a = 5, b = 7} = {a: 1}
    next()を実行しただけ返り値が1増える関数を定義してください
    ```js
    var setUp = function(){
    var count = 0;
    const setUp = function(){
    let count = 0;
    return function(){
    return (count += 1);
    }
    };
    var next = setUp();
    const next = setUp();
    next();//1
    next();//2
    next();//3
    @@ -464,7 +479,7 @@ function Who(name){
    Who.prototype.getName = function(){
    console.log('Myname is ' + this.name);
    };
    var o = new Who('morita');
    let o = new Who('morita');
    o.getName()
    ```
    @@ -476,8 +491,8 @@ o.getName()
    //**shallow copy**
    //プロパティ値や要素値だけのコピーでその先の参照まではコピーしない
    //
    var arr = [{x : 2}];//オブジェクト参照をもつ配列
    var arr2 = [].concat(arr);//要素をコピー
    let arr = [{x : 2}];//オブジェクト参照をもつ配列
    let arr2 = [].concat(arr);//要素をコピー
    arr2[0].x = 123;//変数arr2から見える要素の参照先オブジェクトを変更。
    arr[0].x//変数arrから変更が見える(shallowだから)
    //123
    @@ -492,7 +507,7 @@ arr[0].x//変数arrから変更が見える(shallowだから)
    下記
    ```js
    var array = ['e','a','k','B','c'];
    let array = ['e','a','k','B','c'];
    array.sort();
    ```
    を実行した結果を答えてください
    @@ -509,7 +524,7 @@ array.sort();
    上記の配列を大文字小文字区別なく順番通りにしてください。期待する値```['a','B','c', 'e','k']```
    ```js
    var array = ['e','a','k','B','c'];
    let array = ['e','a','k','B','c'];
    array.sort(function(a,b){
    return a.toUpperCase() > b.toUpperCase() ? 1 : -1 ;
    });
    @@ -525,7 +540,7 @@ array.sort(function(a,b){
    期待する結果```[100, 35, 20, 3, 0]```
    ```js
    var numArray = [20,100,3,35,0];
    let numArray = [20,100,3,35,0];
    numArray.sort(function(a,b){
    return b - a;
    });
    @@ -541,7 +556,7 @@ return a - b
    '10'をNumber型にし、型判定し、数値かどうか評価後、文字列に変換してください
    ```js
    var a = +'10';
    let a = +'10';
    typeof a
    //number
    isNaN(a);
    @@ -550,7 +565,7 @@ a.toString();
    //'10'

    //other
    var a = parseInt('10', 10);
    let a = parseInt('10', 10);
    ```
    **問25**
    @@ -595,7 +610,7 @@ function Factory(name){
    }
    }
    };
    var fafa = Factory('morita');
    const fafa = Factory('morita');
    fafa.introduce()
    //morita
    ```
    @@ -607,13 +622,13 @@ applyの第一引数にnullを渡す場合とオブジェクトを渡す場合
    p83
    ```js
    var sayHi = function(name){
    let sayHi = function(name){
    return 'hello!' + (name ? name : '');
    };
    sayHi('kenji');
    sayHi();
    sayHi.apply(null,['kenji']);//関数呼び出し
    var greeting = {
    let greeting = {
    sayHi: function(name){
    return 'hello!' + (name ? name : '');
    }
    @@ -629,12 +644,12 @@ greeting.sayHi.apply(greeting);//渡さない
    **問28**
    ```js
    var obj = {x : 2, y: 3};
    let obj = {x : 2, y: 3};
    ```
    このobjをプロパティ追加不可、削除変更は可能にし、プロパティ追加不可か否かの判定メソッドでtrueが返る事を確認した後、objのkeyを列挙してください。
    ```js
    var obj = {x : 2, y: 3};
    let obj = {x : 2, y: 3};
    Object.preventExtensions(obj);
    Objcet.isExtensible(obj);//true
    Object.key(obj);
    @@ -643,23 +658,23 @@ Object.key(obj);
    **問29**
    こちら```var obj = {}``` と等価をObjctメソッドで生成してください
    こちら```let obj = {}``` と等価をObjctメソッドで生成してください
    ```js
    var obj = Object.create(Object.prototype);
    let obj = Object.create(Object.prototype);

    ```
    **問30**
    こちら
    ```js
    var obj = {x : 2, y: 3}
    let obj = {x : 2, y: 3}
    ```
    と等価をObjectメソッドで生成してください
    ```js
    var obj = Object.create(Object.prototype, {
    let obj = Object.create(Object.prototype, {
    x : {value: 2, writable: true, enumerable: true, configurable: true},
    y : {value: 3, writable: true, enumerable: true, configurable: true}
    })
    @@ -670,7 +685,7 @@ var obj = Object.create(Object.prototype, {
    こちら
    ```js
    var obj = { x : 2}
    const obj = { x : 2}
    ```
    の属性を出力してください
    @@ -691,7 +706,7 @@ Object.getOwnPropertyDescriptor(obj, 'x');
    ```var obj2 = {x : 2};```にObjectメソッドを用いてプロパティ```y```、値```2``````プロパティ追加可能```を定義して、Objectメソッドで情報(値と属性)を返してくださいP149
    ```js
    var obj2 = {x : 2};
    let obj2 = {x : 2};
    Object.defineProperty(obj2, 'y', {value: 3, enumerable: true});
    //[object Object] {
    // x: 2,
    @@ -724,12 +739,12 @@ f(2)
    **問33**
    ```js
    var arr = ['2','23','0','16'];
    let arr = ['2','23','0','16'];
    ```
    を小さい順にソートしてください。その後ソートをできないようにread-onlyにしてください
    ```js
    var arr = ['2','23','0','16'];
    let arr = ['2','23','0','16'];
    arr.sort(function(a,b){ return a - b ;});
    //['0', '2', '16', '23']
    Object.freeze(arr);
    @@ -743,8 +758,8 @@ arr.sort();
    ```var arr = [3,4,5];```をconcat以外で新たな配列として```arr2```にコピーしてください。その後```arr2[0]= 123```を代入するとarrは何を出力するか答えなさい
    ```js
    var arr = [3,4,5];
    var arr2 = arr.slice(0, arr.length);
    let arr = [3,4,5];
    let arr2 = arr.slice(0, arr.length);
    arr2
    //[3, 4, 5]
    arr2[0] = 123;
    @@ -756,7 +771,7 @@ arr2

    //別解

    var arr2 = arr.map(ele => ele);
    let arr2 = arr.map(ele => ele);
    arr2
    //[3, 4, 5]
    ```
    @@ -3102,10 +3117,10 @@ var obj = {
    twon: 'shibuya'
    }
    var {name, twon} = obj;
    obj.name
    "kenji"
    obj.twon
    "shibuya"
    name
    //"kenji"
    twon
    //"shibuya"
    ```
    **問156**
    @@ -3142,7 +3157,7 @@ b
    **問158**
    上記と同じ事をECMAScript2015ライクに簡潔に記述してください
    上記(問157)と同じ事をECMAScript2015ライクに簡潔に記述してください
    ```js
    var a = 1;
    @@ -3597,6 +3612,10 @@ let flat = {};
    })
    flat
    //[0, 1, 2, 3, 4, 5]

    //other
    [...[0, 1], ...[2, 3], ...[4,5]]
    //[0, 1, 2, 3, 4, 5]
    ```
    **問178**
    @@ -3982,13 +4001,14 @@ list.appendChild(fragment);
    ```
    **問WIP-195**
    **問195**
    文字列の中で`\n`があったら全てを`<br>`に置き換える正規表現を表して`replace`してください
    ```js
    var {c:foo, d} = {
    c:"foo",
    d:"bar"
    };
    str = str.replace(/(?:\r\n|\r|\n)/g, '<br>');

    see: [https://stackoverflow.com/questions/784539/how-do-i-replace-all-line-breaks-in-a-string-with-br-tags](https://stackoverflow.com/questions/784539/how-do-i-replace-all-line-breaks-in-a-string-with-br-tags)
    ```
    **問196**
    @@ -4191,6 +4211,9 @@ Object.assign(SomeClass.prototype, {
    ···
    }
    });

    //Object.assing(Someclass.prorotype, {a: fun, b: fun})//コンストラクタをkeyにもつprototypeオブジェクトを返す
    //Object.assing({}, Someclass.prorotype, {a: fun, b: fun})//新たなObjectとして返す
    ```
    **問207**
    @@ -5094,7 +5117,6 @@ pop、push、reverse、shift、sort、splice、unshilft

    </details>
    <details><summary>251〜問300</summary>

    **251**

    ```var arr = ['one', 'two', 'three']```においてarrを不変オブジェクトに変更してください。
    @@ -6419,7 +6441,6 @@ el.setAttribute('tabindex', 3);
    ```
    </details>
    <details><summary>問301〜問350</summary>
    **問301**
    こちら
    @@ -7781,7 +7802,7 @@ greetAwkwardly("kenji");
    ```
    が出力されるようにgreetDeeplyCurriedを実装してください
    ```js
    ```
    var greetDeeplyCurried = function(greeting){
    return function(spread){
    return function(empasis){
    @@ -7853,7 +7874,6 @@ capitalizeFirstLetter("morita")
    //"Morita"
    ```
    **問350**
    prototype と \_\_proto\_\_ の違いを説明してください
    @@ -7942,10 +7962,8 @@ let b = new A('JavaScript');
    //JavaScriptはb上のプロパティcarを探し、見つからなければ上記2で作成されたb.__proto__(A.prototype)を参照し、A.prototypeにあるcarプロパティ値を返すためです。

    ```

    </details>

    <details><summary>問351〜問368</summary>
    <details><summary>問351〜問400</summary>

    **問351**

    @@ -7969,8 +7987,7 @@ f.hasOwnProperty('y')
    **問352**
    こちら
    ```js
    ```
    function a (name) {
    this.name = name;
    }
    @@ -7991,14 +8008,17 @@ b.car


    //4つのことが起こる
    //1.新しい空のオブジェクト{}が生成される
    //1.新しい空のオブジェクト{}が生成される//WIP 仕様確認
    //2.b上に__proto__が作られ、それはa.prototypeを参照するようになる。なのでb.__proto__ === a.prototype
    //3.上記1で生成されたオブジェクトをthisにするもつa.prototype.constructorを実行します。したがってnameプロパティは新しく作成されたオブジェクトに追加されます。
    //4.作成されたオブジェクトを返します。let bは新しいオブジェクトが割り当てられます。
    //もしa.prototype.car = 'BMW'として、b.carとすると" BMW"をアウトプットします
    //JavaScriptはb上のプロパティcarを探し、見つからなければ上記2で作成されたb.__proto__(a.prototype)を参照し、a.prototypeにあるcarプロパティ値を返すためです。
    ```
    http://exploringjs.com/es6/ch_parameter-handling.html#sec_named-parameters
    **問353**
    こちらはmaxからminまでのランダム値を返す関数です。
    @@ -8065,17 +8085,12 @@ typeOf(null, [], NaN);
    //['object', 'object', 'number']
    ```
    **問357**
    文字列 `"hello"`を逆の文字列にしてください expect `"olleh"`
    変数宣言無しで `{ a: "baz", b: 101 }`のそれぞれの値を`a``b`に代入してください
    ```js
    const str = "hello"
    str.split('').reverse().join('')

    //other
    [...str].reduce((prev,next)=>next+prev)
    ({ a, b } = { a: "baz", b: 101 });
    ```
    **問358**
    @@ -8107,11 +8122,45 @@ const {faf, ee } = (() => {
    })()
    ```
    **問359**
    上記のような
    ```js
    [1, 2, 3].map(e => e);
    ```
    いわゆるワンラインで書かれているFanctor内でconsole.logを出力してください
    ```js
    [1, 2, 3].map(e => console.log(e) || e);
    //console.logはundefinedを返すのでfalse。処理が次に移る
    ```
    **問360**
    下記
    ```
    ~1
    ~-1
    ~0
    ```
    3つはそれぞれは何を返すか
    ```js
    -2
    0
    -1
    //符号を逆にして-1された値が返る
    ```
    **問361**
    下記のように
    ```
    ```js
    let a = false
    let b = false
    let variable;
    @@ -8157,13 +8206,22 @@ JSON.stringify(user)
    "{}" //empty
    ``
    why:
    Function properties(method)、Symbolic properties、 値がundefinedなpropertiesはskipされます
    `Function properties(method)`
    `Symbolic properties`
    `値がundefinedなproperties`はskipされます
    JSON typeとしてサポートされているのは以下です
    ```
    Objects { ... }
    Arrays [ ... ]
    Primitives: strings,numbers, boolean values true/false, null.
    aside
    'John' became "John", `{age: 30}` become `{"age": "30"}`
    ```
    _aside_
    `'John'` became `"John"`, `{age: 30}` become `{"age": "30"}`
    `typeof user` will return `"string"`
    @@ -8204,8 +8262,11 @@ VM2804:1 Uncaught TypeError: Converting circular structure to JSON
    at <anonymous>:1:6
    ```
    why:
    循環オブジェクト参照構造体を文字列に変換できません。
    簡単に言うと、
    参照がその参照を参照してその参照がさらにその参照をしてと繰り返されることです
    ```js
    @@ -8236,12 +8297,17 @@ a.childは参照先bの構造も変わるので
    a.child.childになります
    さらにb.childはaを参照するので.childがあり、と延々続くのですね


    このようなケースを文字列にする場合失敗します
    ```
    このようなケースを文字列にする場合失敗すると言うことです
    回避するには
    ```js
    JSON.stringify(value[, replacer, space])
    [replacer](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)を設定します
    ```

    //[replacer](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify)を設定します

    var obj = {
    a: "foo",
    b: obj
    @@ -8261,7 +8327,7 @@ let str = '{"title":"Conference","date":"2017-11-30T12:00:00.000Z"}';
    ```
    をJSだけで(moment.jsを使わず) dateの日付(この場合30)を返す関数を作ってください
    ```
    ```js
    let str = '{"title":"Conference","date":"2017-11-30T12:00:00.000Z"}';
    let meetup = JSON.parse(str, function(key, value) {
    if (key == 'date') return new Date(value);
    @@ -8317,19 +8383,24 @@ user
    **問366**
    こちら
    ```js
    alert( undefined || null || 0 );

    ```
    を実行すると何がalertとして表示されますか?
    ```
    ```js
    0
    ```
    chain of OR "||" returns the first truthy value or the last one if no such value is found.
    `chain of OR "||" returns the first truthy value or the last one if no such value is found.`
    ORはtruthy valueかそのような値が見つからない場合最後の値を返します
    ```
    _aside_
    ```js
    alert( 1 || 0 ); // 1 (1 is truthy)
    alert( true || 'no matter what' ); // (true is truthy)
    alert( null || 1 ); // 1 (1 is the first truthy value)
    @@ -8344,15 +8415,21 @@ alert( undefined || null || 0 ); // 0 (all falsy, returns the last value)
    ```js
    alert( alert(1) || 2 || alert(3) );
    ```
    どうなりますか
    ```js
    `1、2とアラートされます`
    ```
    12とアラートされます
    ```
    why
    alertはundefinedを返します
    最初のOR評価でalertとして実行し1のメッセージ
    undefineを返すので、ORはtruthyを探しに次のオペランドへ2が返るのでORはそこで終わり、
    外側のアラートがそれを実行します
    @@ -8364,8 +8441,11 @@ undefineを返すので、ORはtruthyを探しに次のオペランドへ2が返
    /hoge.fefe/.test(`hoge
    fefe`);
    ```
    は正規表現内で全ての文字にマッチ「.」を使用しています。test引数内で改行を含める文字列にマッチさせるためです。
    が、こちらはfalseが返ります。
    trueになるようにしてください。
    ```js
    @@ -8376,24 +8456,156 @@ fefe`)
    **問369**
    Numberオブジェクトに引数をとって加算できるplusメソッドを追加してください
    ```js
    WIP
    Object.defineProperty(
    Number.prototype,
    "plus", {
    value: function (b) {
    return this + b;
    }
    }
    );
    ```
    [RegExp Named Capture Groups](https://github.com/tc39/proposal-regexp-named-groups)
    **問370**
    // RegExp Lookbehind Assertions
    `a`という変数に`{}`かkeyがあるかどうか評価してください
    ```js
    Object.keys(a).length === 0
    ```
    **問371**
    このような `{foo: "hogehoge", bar: "fafa"}``{bar: "fafa"}``{foo: "hogehoge"}``null` が渡って来る可能性がある関数がある。
    ```js
    const buildAnObjectFromAQuery = (query) => {
    const object = {};
    if (query.foo) {
    object.foo = query.foo;
    }
    if (query.bar) {
    object.bar = query.bar;
    }
    return object;
    }
    ```
    上記の関数と同じ仕事をする関数をより端的に書いてください。
    ```js
    const buildAnObjectFromAQuery = query => ({
    ...query.foo && { foo: query.foo },
    ...query.bar && { bar: query.bar },
    });
    ```
    **問372**
    このような `[1,2,3,3]` 配列がある。 `[1,2,3]` とユニークな要素だけを取得するようにしてください
    ```js
    let un = [...new Set([1, 2, 3, 3])]
    console.log(un); //[1, 2, 3]
    ```
    **問373**
    このようなfalsyな値を含む配列がある。
    ```js
    let e = [0, undefined, null, "", 21, "fafa", false]
    ```
    それらを除外した ```[21, "fafa"]```を取得してください
    ```js
    let e = [0, undefined, null, "", 21, "fafa", false]
    let trusy = e.filter(Boolean);
    console.log(trusy);// [21, "fafa"]
    ```
    **問374**
    引数が渡って来ない、`undefined` なら Errorをthrowする関数を書いてください
    ```js
    const required = ()=> { throw new Error("ooops") }
    const fn = (param = required()) => {
    console.log("ok")
    }
    fn()// Error
    fn(undefined) //Error
    fn(null) // ok
    fn("") //ok

    ```
    **問題375**
    文字列 `"hello"`を逆の文字列にしてください expect `"olleh"`
    ```js
    const str = "hello"
    str.split('').reverse().join('')
    //other
    [...str].reduce(( prev, next ) => next + prev)
    ```
    **問題376**
    ```js
    ```
    **問題377**
    ```js
    ```
    **問題378**
    ```js
    ```
    **問題379**
    ```js
    ```
    **問題380**
    ```js
    ```
    **問題381**
    ```js
    ```
    **問題382**
    ```js
    WIP
    ```
    [https://github.com/tc39/proposal-regexp-named-groups](https://github.com/tc39/proposal-regexp-lookbehind)
    **問題383**
    ```js
    ```
    **問題384**
    ```js
    ```
    **WIP**
    @@ -8427,6 +8639,73 @@ fun(1)
    //1
    ```
    ```js

    下記の関数

    function f(images, index, attributes){
    return {images: [ ...images.slice(0, index), {...images[index], ...attributes}, ...images.slice(index + 1)]}
    }
    f(["eeee","ppp","lll"], 1, [1,2,3])
    実行時出力結果を答えてください


    //images:[ "eeee", {0: 1, 1: 2, 2: 3} ,"lll"]
    ```
    [付録] 便利かもしれないユーティリティ関数
    ```js

    var object = {
    innerObject:{
    deepObject:{
    value:'Here am I'
    }
    }
    };

    if(object && object.innerObject && object.innerObject.deepObject && object.innerObject.deepObject.value) {
    console.log('We found it!');
    }
    ```
    このように退屈なif文にならないためのユーティリティ関数
    ```js
    var obj = {
    innerObject: {
    deepObject: {
    value: 'Here am I'
    }
    }
    };

    function hasOwnDeepProperty(obj, prop) {
    if (typeof obj === 'object' && obj !== null) { // only performs property checks on objects (taking care of the corner case for null as well)
    if (obj.hasOwnProperty(prop)) { // if this object already contains the property, we are done
    return true;
    }
    for (var p in obj) { // otherwise iterate on all the properties of this object
    if (obj.hasOwnProperty(p) && // and as soon as you find the property you are looking for, return true
    hasOwnDeepProperty(obj[p], prop)) {
    return true;
    }
    }
    }
    return false;
    }

    console.log(hasOwnDeepProperty(obj, 'value')); // true
    console.log(hasOwnDeepProperty(obj, 'another')); // false

    ```
    </details>
    @@ -8461,6 +8740,13 @@ http://azu.github.io/promises-book/
    http://exploringjs.com/es2016-es2017/ch_async-functions.html#_writing-asynchronous-code-via-generators
    https://github.com/loverajoel/jstips
    https://www.sitepoint.com/react-higher-order-components/
    https://www.sitepoint.com/5-typical-javascript-interview-exercises/?utm_content=buffer5f461&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer
    http://www.jstips.co/en/javascript/
    http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/#more-1037
    https://www.sitepoint.com/currying-in-functional-javascript/
    https://stackoverflow.com/questions/9959727/proto-vs-prototype-in-javascript
    https://ponyfoo.com/articles/es6-array-extensions-in-depth
    https://speakerdeck.com/wakamsha/sore-motutosumatonishu-keruyo-javascript-kodowomotutoduan-ku-motutosinpurunishu-ku-tips-4xuan
    https://javascript.info/js
    https://davidwalsh.name/javascript-tricks
    </details>
  27. kenmori revised this gist Nov 30, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -8073,6 +8073,9 @@ typeOf(null, [], NaN);
    ```js
    const str = "hello"
    str.split('').reverse().join('')

    //other
    [...str].reduce((prev,next)=>next+prev)
    ```
    **問358**
  28. kenmori revised this gist Nov 30, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -7852,9 +7852,7 @@ function capitalizeFirstLetter(string) {
    capitalizeFirstLetter("morita")
    //"Morita"
    ```
    </details>
    <details><summary>問350〜問368</summary>
    **問350**
    @@ -7945,6 +7943,10 @@ let b = new A('JavaScript');

    ```

    </details>

    <details><summary>問351〜問368</summary>

    **問351**

    問352を参照にして、自身にyプロパティをもつFクラスのインスタンスfがFのprototypeオブジェクトを参照していることを証明してください。尚、Fはclass構文とする
  29. kenmori revised this gist Nov 29, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -7854,7 +7854,7 @@ capitalizeFirstLetter("morita")
    ```
    </details>
    <details><summary>問351〜問368</summary>
    <details><summary>問350〜問368</summary>
    **問350**
  30. kenmori revised this gist Nov 29, 2018. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions JavaScript.md
    Original file line number Diff line number Diff line change
    @@ -7852,6 +7852,9 @@ function capitalizeFirstLetter(string) {
    capitalizeFirstLetter("morita")
    //"Morita"
    ```
    </details>
    <details><summary>問351〜問368</summary>
    **問350**