This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScriptの継承について | |
//JavaScriptはJavaやC++のようにクラスベースの言語ではありません | |
//JavaScriptはプロトタイプベースの言語です | |
//なのでJavaScriptのオブジェクトは他のオブジェクトとプロトタイプによる繋がりを持っています | |
//これを利用して継承をするのです | |
//ではまずメインのオブジェクトをつくります | |
var Human = function(name, age){ | |
this.name = name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScriptのスプレッド演算子 | |
//これは ECMAScript 6 から導入されたものです | |
//使用できない環境もあります | |
//これは | |
//配列の値を別々にして評価するものです | |
//文字ではわかりにくいと思うので、まずはこれを見てください | |
var arrA = [0,1,2]; | |
var arrB = [3,4,5]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScriptの while, do...while について | |
//while はJavaScriptの基本的な反復処理をするための構文です | |
//while ([条件式]) {[反復処理]} | |
//という風に書きます | |
//条件式がまず最初に評価され true の場合は反復処理が実行されます | |
//false の場合は処理が終了します | |
var count = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScriptのfor,for...in,for...ofについて | |
//今回はJavaScriptのfor系の文について説明していきます | |
//for系の文はどれも | |
//条件を検査し当てはまる場合繰り返し処理をする | |
//ものになっています | |
//for について | |
//forは最も基本的な繰り返し処理です | |
// for ([初期化式]; [条件式]; [処理式]) { [繰り返し処理] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScriptのcallとapplyとbindについて | |
//JavaScriptのthisの指すオブジェクトでハマったので書き残しておきます | |
//まずこれを理解するにはJavaScriptのthisのついてある程度理解しておく必要があります | |
//また解説にプロトタイプも使用しますので悪しからず | |
//まずこれを見てください | |
var _foo = function(){ | |
this.name = "FOO"; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScriptのGetter,Setterについて | |
//あなたも一度は思ったことでしょう | |
//JavaScriptでプライベートな変数を使いたい… | |
//とね | |
//この説明を見ればその願いは叶うでしょう | |
//まずはGetterとSetterについて | |
//この二つはプライベートな変数にアクセスする橋のようなものです | |
//この二つはオブジェクトの中で使います | |
//例えば |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ECMAScript 6から導入された | |
//デフォルト仮引数と残余仮引数について | |
//JavaScriptの関数の仮引数は指定しなかった場合 | |
//undefined | |
//となります | |
//今まではデフォルト値を設定する場合 | |
function foo(a, b){ | |
var b = (typeof b === "number") ? b : 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//三項演算子について | |
//最近三項演算子がつよいと思ったんです | |
//三項演算子とは | |
// [条件式] ? [trueの場合] : [falseの場合]; | |
//という風に条件分岐をコンパクトにできるものです | |
//例えばこれ | |
function num(n){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScriptのプロトタイプについてJavaっぽく説明します | |
//プロトタイプとは | |
//他のオブジェクトとの内部的な繋がりです | |
//概念レベルの話ですね | |
//噛み砕いて言うとロープのようなものです | |
//まぁ、正直ここはどうでもいいです | |
//重要なのはここから | |
//基本的なことは知ってると仮定して話をすすめます | |
//今回説明していくのはnewを使った実用的なコードです |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//JavaScriptのクロージャ解説 | |
//クロージャはいろいろできる(結論) | |
//例えばクラスっぽいこともできる | |
//私的に一番好きなのはプライベートなメソッドが作れるということ | |
//例えば | |
var yourName = (function(){ | |
var selfName = "undefind"; | |
var _setName = function(string){ | |
selfName = string; |
NewerOlder