목록공부/JavaScript (40)
컴퓨터는 잘못이 없다..
[Array Type 특징] 1. typeof 연산자 └사용예 - typeof 변수명 - typeof 데이터타입명 ex) typeof num1 ex) typeof array 2. array type -순서가 중요한 데이터를 담는다 -대괄호 [] 리터럴을 이용해서 만들 수 있다. -0부터 시작해서 1씩 증가하는 인덱스가 자동 부여된다. -array type의 데이터를 변수에 저장하고 실제로 typeof 변수 해보면 object 가 출력된다. -array도 object의 부분집합이다. (array도 object이다.) -array도 object이기 때문에 변수에 참조값을 담아둔다. let nums = [10,20,30,40,50]; let names = ["김구라","해골","원숭이"]; 3. array t..
[if~else문 설명] -양자 택일의 if~else문 if(){ ... }else{ ... } [if~else문 예제코드] boolean type 테스트중...
[if문과, 예약어 종류, confirm함수] -if문 형태 if(조건문){ ... } 조건문이 true이면 코드를 실행하고 false이면 코드를 실행하지 않는다. -예약어 종류 var, let, function, return if └이러한 예약어는 변수명으로 사용할 수 없다. -confirm() 함수 └확인을 누르면 true, 취소를 누르면 false를 return해주는 함수 01) 예제코드 boolean type 테스트
[document.querySelectorAll() 사용해보기] document.querySelectorAll()를 사용하여 div태그의 innerText를 바꿔보자 document.document.querySelectorAll("div")가 의미하는 것? -> 모든 div 각각의 참조값이 배열요소로 들어가 있어 배열 index로 접근가능하다. -> div가 위에서 아래로 쌓인 방향대로 index가 0인 방부터 차례대로 들어간다. [예제코드] div1 div2 div3 div4 div5 바꾸기 [코드결과] document.querySelector()의 반환타입은 array type! 따라서 index로의 접근이 가능하다.
[return 예약어] 1.return 예약어 └함수를 호출하면 결과값을 return 해준다. └return이 없거나 return 옆자리가 휑하면? undefined를 return해준다./또한 실행코드를 다 수행하고 함수가 종료된다. └함수를 호출해 함수가 실행되다가 return을 만나면 함수가 종료된다. 종료된 후 함수를 호출 한 곳으로 돌아간다. └함수를 호출하면 그 함수는 return값 그 자체가 된다.라고 생각하기!!!!★★★★★ ex) return 10 인 b()함수를 호출하면 b() 는 10(number type)이 된다. ex) data = [{객체1},{객체2},{객체3}]이고 return data인 getData() 함수를 호출하면 getData()는 [{객체1},{객체2},{객체3}](..
[ECMA5버전,ECMA6버전 자바스크립트] 1. ECMA5 버전과 ECMA6버전 javascript 비교해보기 └ECMA5 버전 -변수 선언은 var로 -문자열은 ""와 +로 표현한다. "안녕" + name └ECMA6 버전 -변수 선언은 let로 -문자열은 back tick과 ${}로! `안녕 ${name}` [object의 참조값을 받는 매개변수를 가진 함수] 1. object의 참조값을 받는 매개변수를 가진 함수 만들기 └함수 : function 함수명(매개변수명){매개변수명.~~}; ex) function a(objmem){name = objmem.name}; └인자전달은? ex) 함수명 : example, mem1 = {num:1, name:"김구라"} 방법1) example(mem..