TIL/Today I Learned
[Develop] 23.05.30 개발 공부 일지
임성장
2023. 5. 30. 23:50
728x90
요약: 자바스크립트 기초문법, 굽네 웹페이지 제작
일시: 23.05.30 09:30 ~ 18:20
장소: 더휴먼컴퓨터아트아카데미
배운 점:
<script>
function CheckWeight(name, height, weight){
this.userName = name;
this.userWeight = weight;
this.userHeight = height;
this.minWeight;
this.maxWeight;
this.getInfo = function(){
let str = '';
str += "이름: "+this.userName+", ";
str += "키: "+this.userWeight+", ";
str += "몸무게: "+this.userHeight+"<br>";
return str;
}
this.getResult = function(){
this.minWeight = ((this.userHeight-100)*0.9)-5;
this.maxWeight = ((this.userHeight-100)*0.9)+5;
if(this.userWeight >= this.minWeight && this.userWeight <= this.maxWeight){
return "정상몸무게입니다."
}else if(this.userWeight < this.minWeight){
return "미달몸무게입니다."
}else{
return "초과몸무게입니다."
}
}
}
let ho = new CheckWeight("123", 178, 70);
document.write(ho.getInfo())
document.write(ho.getResult())
</script>
<pre>
// 객체 생성자 함수
function 함수명(매개변수1, 매개변수2,...매개변수n){
this.속성명 = 새로운 값;
this.함수명 = function(){
자바스크립트 코드;
}
}
let 참조 변수(인스턴트 네임) = new 함수명();
let 참조 변수 = {속성: 값, 함수명 : function(){.....}}
</pre>
<h2>math method</h2>
<ul>
<li>max(x, y) - 둘 중 큰 값</li>
<li>min(x, y) - 둘 중 작은 값</li>
<li>round(x) - x 값의 소수점 첫째자리를 반올림</li>
<li>ceil(x) - 소수점 자리를 무조건 올림</li>
<li>floor(x) - 소수점 자리를 무조건 절삭</li>
<li>random(x) - 0과 1사이 난수를 발생</li>
<li>abs(x) - 수의 절대값을 반환</li>
</ul>
- 객체
- 아코디언 메뉴
부족한 점:
728x90