JSでの変数タイプ
7679 ワード
変数#ヘンスウ# JSでtypeofを使用して得られるタイプ は、==および== をいつ使用するか JSにはどのような内蔵関数がありますか JS変数は、格納方法によってどのようなタイプに分類され、その特徴を説明します. 変数タイプ 値タイプ 参照タイプ
JSON の理解方法
変数計算-強制型変換文字列接合 ==演算子 if文 論理演算子
typeof undefined //undefined
typeof 'abc' //string
typeof 123 //number
typeof true //boolean
// ,typeof
typeof {} //object
typeof [] //object
typeof null //object
typeof console.log //function
if (obj.a == null) {
// obj.a === null || obj.a === undefined
// jqurey
}
Object
Array
Boolean
Number
String
Function
Date
RegExp
Error
var a = 100
var b = a
a = 200
console.log(b) //100
var a = { age: 20 }
var b = a
b.age = 21
console.log(a.age) //21
//JSON JS
JSON.stringify({ a: 10, b: 20 })
JSON.parse('{"a":10,"b":20}')
変数計算-強制型変換
var a = 100 + 10 //110
var b = 100 + '10' //'10010'
100 == '100' //true
0 == '' //true
null == undefined //true
var a = true
if (a) {
//...
}
var b = 100
if (b) {
//...
}
var c = ''
if (c) {
//...
}
console.log(10 && 0) //0
console.log('' || 'abc') //'abc'
console.log(!window.abc) //true
// true false
var a = 100
console.log(!!a) //true