値と変数


数値


整数式は指定されていません.すべての数値は分配密度(二重精度)浮動小数点(浮動小数点)数です.
1/2 // 0 이 아닌 0.5 반환
3.5 % 1.2 // 1.1
'hello'.substring(0, 2.5) // 'he'
'hello'[2.5] // undefined
0/0 //NaN
'hello 🌐'.length // 8

仏利恒


0、NaN、null、undefined、および「」のブール値はfalse、残りはtrue
変数を初期化しない場合はundefinedを使用します.意図的な値にはnullを使用します.undefinedのみを使用します.

かたわく

`Hello, ${'world'.toUpperCase()}` // 'hello, WORLD'  템플릿리터럴

オブジェクト範囲の

let age = 43
let harry = { name: 'Harry', age }
let harry = { name: 'Harry', [field.toLowerCase()]: 42 }
let harry = { name: 'Harry', 'your age': 42 }
harry['your age'] = 33

整列

const someNumbers = [ , 2, ,3] 
someNumbers[0] // undefined
someNumbers.length // 4

JSON


オブジェクト文字、配列文字、文字列、小数点数、true、false、nullを値として使用
文字列を二重引用符で区切る
Property名は二重引用符で区切られています
末尾に単純タグを付けられません
JSON.stringifyオブジェクトをJSON文字列に変換
JSON.parse JSON文字列をオブジェクトに分割
オブジェクトを記録するときに文字列に含めるべきではありません
console.log(`harry=${harry}`) // harry=[object Object]
console.log('harry=', harry) // harry={ ... }

非構造化

let [first, second] = ['one', 'two']
let [first, [second, third]] = [1, [2,3]]
let [first, second] = ['one'] // second 는 undefined
let { name, age } = { name: 'harry', age: 44 }
let { birthday: { year: patsBirthday }} = { name: 'pat', birthday: { day: 14, month: 3, year: 2002} } // patsBirthday = 2002
let [first, second, ...others] = [1, 2, 3, 4] // others 는 [3, 4]
let [first, second, ...others] = [4] // first 는 4, second 는 undefined, others 는 []
let { name, ...allButName } = { name: 'harry', age: 42, id: 11122 } // name 은 harry, allButName 은 { age: 42, id: 11122 }
let [first, second = 0] = [44] // second 는 0

練習問題


01
0+NaN+Infinity+fasle+true+null+undefined // NaN
''+NaN+Infinity+fasle+true+null+undefined // 'NaNInfinityfalsetruenullundefined'
02
[]+[] // ''
{}+[] // 0 , {} 블록
[]+{} // '[object Object]'
{}+{} // '[object Object][object Object]'
[]-{} // NaN
03
-1%2 // -1
-2%2 // -0
-3%2 // -1
-4%2 // -0
-1.2%2 // -1.2
-2.3%2 // -0.2999999999999998
-2.4%2 // -0.3999999999999999
04