JS30 Array.from() 정리 (JavaScript) let arr1 = Array.from('Hello'); console.log(arr1); console.log("type : " + typeof(arr1)); let arr2 = Array.from([1, 2, 3, 4], x => x + x); console.log(arr2); console.log("type : " + typeof(arr2)); let arr3 = Array.from({ 0 : 'one', 1 : 'two', 2 : 'three', length : 3});console.log(arr3);console.log("type : " + typeof(arr3)); 문자열, 배열, 객체를 Array 오브젝트로 반환한다. 2020. 8. 6. const 변수 정리(JavaScript) const CHOA = "Hello World"CHOA = "Bye Bye" const로 정의된 상수에 새로운 값을 할당하면 Assignment to constantvariable 에러가 발생한다. if(true){const FOO = "GUGUGU";}console.log(FOO); const로 정의한 FOO 변수는 if문 블록 밖에서 접근할 경우 ReferenceError가 발생한다. (Block Scope) const client = {name: 'foo',age : 20};console.log(client.name, client.age); client.name = 'bar';client.age = "30";console.log(client.name, client.age); client = {reg.. 2020. 8. 6. Function Scope VS Block Scope 스코프 (JavaScript) if(true){var foo = "Global";let bar = "local";} console.log("var foo : " + foo);console.log("let bar : " + bar); var로 정의한 foo 변수는 if문 블록 밖에서도 접근 가능하다. (Function Scope)let으로 정의한 bar 변수는 if문 블록 밖에서 접근할 경우 ReferenceError가 발생한다. (Block Scope) 2020. 8. 6. addEventListener, Window.innerWidth 활용(JavaScript) DOCTYPE html> Document Hello JavaScript!! const title = document.querySelector("body");const colors = ["#1abc9c", "#3498db", "#9b59b6", "#f39c12", "#e74c3c", "#C18282", "#FF50CF","#0A9696"];const RESIZE_CLASS = title.style.backgroundColor = colors[0]; function handleResize() { var wframe = window.innerWidth console.log(wframe); if(wframe200 &&wframe 400 &&wframe 600 &&wframe 800 &&wframe 1000 &&.. 2020. 8. 6. 이전 1 2 3 4 5 ··· 8 다음