# what is javascript? I ###### 參考 https://cythilya.github.io/2018/10/09/intro-1/ 1. falsy Value ```javascript= if (false) if (null) if (undefined) if (0) if (-0) if (0n) if (NaN) if ("") ``` 2. typeof it can get type of value ```javascript= typeof 'Hello World!'; // 'string' typeof true; // 'boolean' typeof 1234567; // 'number' typeof null; // 'object' typeof undefined; // 'undefined' typeof { name: 'Jack' }; // 'object' typeof Symbol(); // 'symbol' typeof function() {}; // 'function' typeof [1, 2, 3]; // 'object' typeof NaN; // 'number' 無效的數字 ``` 3. Equality ==(寬鬆相等性 loose equality)會做強轉型 ===(嚴格相等性 strict equality)不會做強轉型 ```javascript= const a = '100'; const b = 100; a == b; // true,強制轉型,將字串 '100' 轉為數字 100 a === b; // false ``` 4. reference or value arrays in JS are reference values, also object and function ###### https://www.samanthaming.com/tidbits/35-es6-way-to-clone-an-array/ ```javascript= var a = [1,2,3] b = a a[0] = 5 console.log(a[0]) // 5 a & b assgin same place console.log(b[0]) // 5 // if you want copy var a = [1,2,3] c = Array.from(a); a[0] = 5 console.log(a[0]) // 5 console.log(b[0]) // 1 ``` ```javascript= let x, y = (1, 2) // , = comma // let x // y = (1,2) comman operator returns the value of the last operand. console.log(x) //undefined console.log(y) //2 ``` ###### tags: `JavaScript`