Created
January 7, 2014 06:35
-
-
Save wolftatsu/8295463 to your computer and use it in GitHub Desktop.
JavaScript 変数宣言時の型を確認する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
console.log("start!!"); | |
// この時点ではまだ未定義(undefined) | |
// typeof() で変数の型を確認することができます | |
var x; | |
console.log("variable x is " + typeof(x)); | |
console.log("x = " + x); | |
// やっと型がnumberになる | |
x = 0; | |
console.log("variable x is " + typeof(x)); | |
console.log("x = " + x); | |
// 期待する結果 | |
x = x + 10; | |
console.log("variable x is " + typeof(x)); | |
console.log("x = " + x); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment