본문 바로가기

study/js9

자바스크립트 관련 자바스크립트 이전페이지 이전 페이지로 이동 자바스크립트 이벤트리스너 파라미터 자바스크립트 htmlelement or node to array Array.from(nodelist) 2022. 8. 23.
자바스크립트 프로토타입 콜백 Prototype object는 자동적으로 prototype이 생김 그걸 상속해줄수있음 밑 3개의 콘솔로그의 결과: rabit에는 분명 jump밖에 없는데 animal의 인스턴스가 출력이 되는 이유는 js가 자식에게 찾는 값이 없으면 부모한테 가서 찾기때문. 자바에서의 상속과 비슷하다. 부모에 속성을 추가하면 자식에도 자동적으로 적용 가능 ++ 추가적으로 더 공부해봄 다른 자료형의 프로토타입도 살펴보면 많은 메서드들을 볼 수 있음. 짱인디? 와우 내가 직접 함수를 만들어서 특정 클래스나.. 객체?에 적용도 가능 콜백함수 ++ 수업때 졸아서 제대로 못들었다 ㅋㅋ 따로 보충 고고 정의 함수에 파라미터로 들어가는 함수 용도 순차적으로 실행하고 싶을때 쓴다. function product(callback) { .. 2022. 5. 24.
나름 재밌는 js 기존 답 코드 let list_zone = document.getElementById('inner_list'); let ul_li = list_zone.children; ul_li = [...ul_li]; console.dir(ul_li[0]); let bigPhoto = document.querySelector('#photo').children[0]; ul_li.map((element, index) => { let aTag = element.children[0]; aTag.onclick = () => { bigPhoto.src = aTag.href; console.log(aTag.href); return false; }; }); //이전,다음 버튼을 클릭할떄마다 이 100만큼 증가 또는 감소되어 좌우측.. 2022. 5. 21.
JavaScript Array 정리! (feat. 드림코딩 앨리님) 'use strict'; /* Array 🍕 1. Declaration */ const arr1 = new Array(); const arr2 = [1, 2]; // 2. Index postion const fruits = ['🍎','🍌']; console.log(fruits); console.log(fruits.length); console.log(fruits[0]); console.log(fruits[1]); console.log(fruits[2]); console.log(fruits[fruits.length - 1]); // 마지막 인덱스 //3. Looping over an array //print all fruits // a. for for ( let i = 0 ; i console.log(fr.. 2022. 1. 10.
JavaScript Object 정리 (feat. DreamCoding Ellie~) /* Objects one of the Javascript's data types. a collection of related data and/or functionality. Nearly all objects in JavaScript are instance if Object object = { key : value }; */ //1. Literals and properties //objdect 만드는법 const obj1 = {}; //'object literal' Syntax const obj2 = new Object(); //'object constructor' syntax // const name = 'ellie'; // const age = 4; // print(name, age); //이렇게 하.. 2022. 1. 9.
자바스크립트 클래스와 오브젝트! (feat. 드림코딩 by 엘리님) 엘리쌤 사랑해용 'use strict' /* Object-oriented programming class: template object: instance of a class JavaScript classes - introduced in ES6 - syntactical sugar over prototype-based inheritance 1. Class declarations */ class Person { //constructor constructor(name, age) { //fields this.name = name; this.age = age; } //methods speak() { console.log(`${this.name}: hello!`); } } const ellie = new Person.. 2022. 1. 8.
728x90