본문 바로가기
java,css,html

java

by 데이터 퍼즐 2021. 8. 14.
반응형

#ctrl+/ = 주석처리

 

1) 반복문

for (var i=0; i<a.length ; i++){
    console.log(a[i]) # 길이만큼 반복

 

#while은 조건과 함께 실행

var i =0;

while(i<11){

    document.write('화면에 찍어주세요.')

    document.write('<br>')

    i=i+1

}

 

#do while은 나중에 조건을 실행

var i =0;

do{

    document.write('화면에 찍어주세요')

    document.write('<br>')

    i=i+1

}while(i<5)

 

2) a.indexOf("특정 선택자") #순서 출력

 

3) 객체출력

<script>

function Car(a, b, c){

    this.name=a;

    this.color=b;

    var move=c;

}

 

var a = new Car("현대", "노란", "전진")

console.log(a.name);

console.log(a.color);

console.log(a.move); #프라이빗 변수

</script>

    

</body>

</html>

 

4) 프로토타입

<script>

function Car(a, b, c){

    this.name=a;

    this.color=b;

    var move=c;

}

Car.prototype.move=function(){

    console.log(this.name + "차이고" + this.color + "색입니다.")

}

var a = new Car("현대", "노란")

a.move()

var b = new Car("기아", "빨강")

b.move()

 

## === 의 경우 형태까지 같아야함(체크)

 

5) 함수표현식과 화살표 함수

화살표함수는 보통 함수 표현식을 축약한 형태로 표시

const sum = function (x,y) { return x+y;

const sum = (x,y) => { return x+y; }

 (매개변수) => {} 

 

6) 기억하기

Undefind : 값 초기화 (var b;)

Null: (var a = null;)

 

7) Jquery 라이브러리 picker

$.fn. : Jquery 프로토타입

 

8) es6: Babel #하위브라우저 커버시 사용

 

9) map, reduce, filter. sort

const num = numbers.map( (x)=>{

return x*10

})

cf. cities.map((x)=> x.count*10)으로 입력시 count값의 10배를 출력

반응형

댓글