#자바스크립트 기본
let a = 1;
let b = "1";
let c = "true";
let d = true;
let e;
let f = null;
console.log(a, b, c, d, e, f);
/*
1.각변수들의 자료형 확인
2.
숫자 number
문자 string
참/거짓 boolean
undefined
null 객체
*/
/*
자료형 확인 - typeof
*/
console.log(
typeof a, //number
typeof b, //string
typeof c, //string
typeof d, //boolean
typeof e, //undefined 변수는 존재하나, 어떠한 값으로도 할당되지 않아 자료형
typeof f //object - null은 객체! 변수는 존재하나, null 로 (값이) 할당된 상태. 즉 null은 자료형이 정해진(defined) 상태
);
let _this = this;
//객체 지향
console.log(_this);
console.log(
_this,
typeof _this, //객체
_this.document //객체 프로퍼티확인
);
/*참 거짓 판별 - Boolean*/
let TA = 0;
let TB = "";
let TC = false;
let TD = !false;
let TE = null;
let TF = undefined;
console.log(
Boolean(TA), //false
Boolean(TB), //false
Boolean(TC), //false
Boolean(TD), //true
Boolean(TE), //false
Boolean(TF) //false
);
/*객체 만들기*/
const k_object = {
name: "mi_suuun",
age: 31,
work: function () {
console.log("리액트 스터디");
},
};
console.log(k_object);
console.log(k_object.name, k_object["name"]);
/*
객체지향 프로그램
프로그래밍에서 필요한 데이터를 추상화시켜 상태와 행위를 가진 객체를 만들고 그 객체들 간의 유기적인 상호작용을 통해 로직을 구성하는 프로그래밍 방법
#장점
-코드 재사용이 용이
-유지보수가 쉬움
-대형 프로젝트에 적합
#단점
-처리 속도가 상대적으로 느림
-객체가 많으면 용량이 커질 수 있음
-설계시 많은 시간과 노력이 필요
https://poiemaweb.com/js-object-oriented-programming
*/
/*배열 만들기*/
//const k_array = [];
const k_array = [1, 2, 3, 4, 5];
console.log(k_array);
console.log(k_array[0]);
/*함수 만들기*/
const k_function = function () {
return "I" + "'" + "m function";
};
console.log(k_function()); //함수 실행
'JS & jQuery' 카테고리의 다른 글
let, const 변수 (0) | 2022.08.28 |
---|---|
자바스크립트 이벤트 (0) | 2022.08.28 |
바닐라 js - tab (0) | 2022.08.16 |
비메오 및 YTPlayer (0) | 2022.08.16 |
scroll img rotate (0) | 2022.07.11 |