728x90

■ JS 변수

var a = 0 // 재할당 , 재선언 가능
let b = 0 // 재할당 만 가능
const c = 0 ; 재할당 , 재선언 불가
 
var test = test || {};

답변에는 왼쪽에 있는 변수(test)가 false, undefined, 0, null etc 일 때 
오른쪽 값으로 넣는다는 것이다. 그냥 쉽게 다른 언어들에 있는 OR 문을 생각하면 될 것 같다.

var a = undefined;
a = a || {};
console.log("a : "+ a);     // "a : [object Object]"
 

■ js foreach

<!doctype html>
<html lang="ko">
<body>
	<input type"text" class="kk" name="kk[]" id="kk1" value="1" />
	<input type"text" class="kk" name="kk[]" id="kk2" value="2" />
	<input type"text" class="kk" name="kk[]" id="kk3" value="3" />
</body>

</html>


<script>
	var result =  { 0:{"professor":"일교수","student":"일학생"} ,
                    1:{"professor":"이교수","student":"이학생"} }

	$.each(result, function (key, item) {
		alert(item.professor);
	});


	$(".kk").each(function (index, item) {
		alert(item.value);
	});

	const arraySparse = [91,92,, 93]
	arraySparse.forEach( function(value, index, item){
		alert(value);
	});
    
    var arr = ['가','나','다','라']; 
    arr.forEach(function(item,index,arr2){ 
      console.log(item,index,arr2[index+1]); 
    }) 

    //첫번쨰 인수는 배열의 각각의 item 
    //두번쨰 인수는 배열의 index 
    //세번째 인수는 배열 그자체

</script>
 

■ 부트스트랩

Extra small (for smartphone)   .col-xs-*  

: 항상 가로로 배치 

Small (for tablets)   .col-sm-*

: 768px 이하에서 세로로 표시 시작

Medium (for laptops)   .col-md-*

: 992px 이하에서 세로로 표시 시작

Large (for laptops / desktops)   .col-lg-*

:1200px 이하에서 세로로 표시 시작 
 
 

 

728x90

+ Recent posts