본문 바로가기

분류 전체보기107

DOM-3 0. classses and attribute ////classes and attribute const firstli = document.querySelector('li:first-child'); const link = firstli.children[0]; //엑스자표시 let val; //classes val = link.className; val = link.classList; val = link.classList[0]; link.classList.add('test'); link.classList.remove('test'); val = link; //attribute val = link.getAttribute('href'); val = link.setAttribute('href', 'http://go.. 2021. 6. 15.
DOM-2 0. traversing the dom traversing: 대상을 바꿔서 체인을 계속하는것. - childNodes -> nodelist 출력 - children -> HTML collection 출력 let val; const list = document.querySelector('ul.collection'); const listitem = document.querySelector('li.collection-item:first-child'); val = listitem; val = list; //get child nodes val = list.childNodes; // 뒤의 띄어쓰기를 text로 지정해 갯수를 셈 //childNodes -> returns nodelists. //get children.. 2021. 6. 14.
DOM-1 0. examining the document type // examining the document type let val; val = document; val = document.all; val = document.all[2]; val = document.all.length; val = document.head; val = document.doctype; val = document.domain; val = document.URL; val = document.characterSet; val = document.contentType; val = document.forms; val = document.forms[0].id; val = document.forms[0].action; val = document.. 2021. 6. 14.
Basics-4 0. prompt : input값을 받아서 alert창으로 띄움 const input = prompt(); alert(input); 1. confirm if(confirm('are you sure')){ console.log('yes'); //확인클릭 -> yes 출력 } else { console.log('no'); //취소클릭 -> no 출력 } 2. Outer & Inner height, width let val; //outer height and width val = window.outerHeight; //window.outerHeight == 현재 윈도우창의 높이 val = window.outerWidth; //window.outerWidth == 현재 윈도우창의 너비 //Inner height.. 2021. 6. 13.
Basics-3 function // loops // iterations 0. FUNCTION DECLARATIONS //FUNCTION DECLARATIONS function greet(firstname, lastname){ return 'hello '+ firstname + lastname; } console.log(greet('nick', ' james')); // hello nick james function greet(firstname = 'nick', lastname = ' james'){ return 'hello '+ firstname + lastname; } console.log(greet()); //hello nick james 1. FUNCTION EXPRESSIONS const 제곱 = function(x){ return x*x; }; console.log.. 2021. 6. 13.
Basics-2 0. template literals : ` ${ } ` const name = 'Richard'; const age = 30; const job = 'web developer'; const city = 'London'; // without template strings (es5) html = 'name: ' + name + 'age: ' + age +' job: ' +job+'age: '+age+' '; html = '' + 'name: ' + name + '' + 'age: ' + age + '' + 'job: ' + job + '' + 'city: ' + city + '' + ''; function hello(){ return 'hello'; } //with template strings (es6).. 2021. 6. 12.
Basics-1 0. Basics //log to console console.log('hello world '); console.log(123); console.log('true'); var greeting = 'hello'; console.log(greeting); console.log([1,2,3,4,5]); console.log({a:1, b:2}); console.table({a:1, b:2}); console.error('this is some error'); console.clear(); console.warn('this is a warning'); console.time('hello'); console.log('hello world '); console.log(123); console.log('true').. 2021. 6. 12.
address & pointer // malloc // swap // file 0. address & pointer - 포인터의 크기와 메모리의 크기는 관계없음. 포인터의 크기 - 운영체제에 의해 결정된다. 메모리 주소 데이터의 크기는 운영체제의 기본 처리단위와 일치한다. 메모리의 크기- 실제 하드웨어 메모리 RAM의 용량에 따라 정해진다. #include int main(void) { int n = 50; int *p = &n; printf("%p\n",p); // n이라는 변수가 저장되어있는 address를 반환한다. printf("%i\n",*p); // address에 저장되어있는 변수n의 값을 반환한다. } 1. malloc : 문자열복사 ※ strcpy(복사한 내용이 들어갈자리, 복사할 대상) malloc( ) => 괄호 안에 있는 숫자의 크기만큼의 메모리공간을 할당함 .. 2021. 6. 7.
cs50_strlen( ) // iteration // recursion 0. #include #include float average(int length, int array[]); int main(void) { // 사용자로부터 점수의 갯수 받음 int n = get_int("number of scores :"); // 배열 선언 및 사용자로부터 점수 받음 int scores[n]; for (int i=0; i 2021. 6. 2.