웹마스터 팁
[javascript] 기초강좌 | 02 산술, 대입, 증감, 비교연산자
2014.04.01 16:19
Part1-2(2장). 자바스크립트연산자1
(산술, 대입, 증감, 비교연산자)
1. 산술연산자
덧셈 +
res=20+10
res값=30
뺄셈 -
res=20-10
res값=10
곱셈 *
res=20*10
res값=200
나눗셈 /
res=20/10
res값=2
나머지 %
res=20%10
res값=0
Javascript2-1.html
---------------------------------------------------------------
<html>
<head><title> </title>
<script language="javascript">
<!--
document.write("자바스크립트예제"+"<br>");
res = 20 + 10;
document.write(res+"<br>");
res = 20 -10;
document.write(res+"<br>");
res = 20 * 10;
document.write(res+"<br>");
res = 20 / 10;
document.write(res+"<br>");
res = 20 % 10;
document.write(res+"<br>");
//-->
</script>
</head>
<body>
</body>
</html>
---------------------------------------------------------------
2. 대입연산자
덧셈대입 +=
뺄셈대입 -=
곱셈대입 *=
나눗셈대입 /=
나머지대입 %=
Javascript2-2.html
---------------------------------------------------------------
<html>
<head><title> </title>
<script language="javascript">
<!—
res = 20;
document.write("자바스크립트예제"+"<br>");
res +=10;
document.write(res+"<br>");
res -=10;
document.write(res+"<br>");
res *=10;
document.write(res+"<br>");
res /=10;
document.write(res+"<br>");
res %=10;
document.write(res+"<br>");
//-->
</script>
</head>
<body>
</body>
</html>
---------------------------------------------------------------
3. 증감연산자
●전위연산자
피연산자의앞쪽에위치한다
●후위연산자
피연산자의뒤쪽에위치한다
●종류: ++ , --
(예) res++,res--, ++res,--res
Javascript2-3.html
---------------------------------------------------------------
<html>
<head><title> </title>
<script language="javascript">
<!--
a = 10;
b = 20;
c = 3;
document.write("자바스크립트예제"+"<br>");
document.write(++a +"<br>");
document.write(a++ +"<br>");
document.write(c++ +"<br>");
document.write(++a + b++ +"<br>");
document.write(++a + ++b +"<br>");
//-->
</script>
</head>
<body>
</body>
</html>
---------------------------------------------------------------
[실행결과]
자바스크립트예제
11
11
3
33
36
4.비교연산자
작다 <
크다 >
작거나같다 <=
크거나같다 >=
같다 ==
같지않다 !=
Javascript2-4.html
---------------------------------------------------------------
<html>
<head><title> </title>
<script language="javascript">
<!--
a = 10;
b = 5;
c = a > b;
document.write("자바스크립트예제"+"<br>");
document.write(c +"<br>");
c = a < b;
document.write(c +"<br>");
c = a == b;
document.write(c +"<br>");
c = a != b;
document.write(c +"<br>");
//-->
</script>
</head>
<body>
</body>
</html>
---------------------------------------------------------------
[실행결과]
자바스크립트 예제
true
true
false
false
true
- [2015/10/27] 묻고답하기 모바일에서 이런 갤러리박스 오픈소스 없을까요.. *1
- [2015/08/10] 묻고답하기 javascript 질문드립니다.
- [2014/04/01] 웹마스터 팁 [javascript]기초강좌 | 01 자바스크립트개념
- [2014/02/14] 웹마스터 팁 GNB 메뉴를 쉽게 만드는 jQuery plugin *2
- [2011/06/30] 묻고답하기 textyle 관련 질문입니다.
댓글 0
제목 | 글쓴이 | 날짜 |
---|---|---|
강좌는 아니지만, 제가 쓸 강좌가 어떤방향으로 나아가야하는지를 잘 모르겠습니다. 그래서 글올립니다. [4] | Dopesoul | 2002.09.06 |
[Lindox] 설치 강좌 쓸때 유용한 명령어 [4] | NeSTY♨™ | 2002.11.05 |
[초초초(X999)허접강좌]사용자들이 하는 작업 강제 취소,IP막기 [5] | -=:{Inuri}:=- | 2002.12.21 |
여러강좌에서 본 내용들을 초보님들을 위해 정리했습니다 [2] | 공유기시로! | 2003.01.21 |
[성공했음]Apache에서 ASP돌리기 (Apache::ASP이용) for Windows 초고속강좌 [9] | 한희진 | 2003.02.05 |
iis + php + mysql 강좌 (윈도우설치) [5] | 이성헌 | 2003.06.01 |
mysql 강좌 .. 요약본 [4] | 이성헌 | 2003.06.05 |
개인서버를만들어보자!(1편 유저생성)(동영상강좌) [8] | 타키 | 2003.10.22 |
[초보강좌] 윈도우 서버의 용량 제한~~!! [17] | HoYa™ | 2004.01.08 |
-초보의 초보대상 강좌-커널 패치하기... [2] | 87K300 | 2004.03.19 |
winXP + APM + 제로보드 이용한 홈피제작(동영상강좌) [1] | kim | 2004.12.04 |
[javascript]기초강좌 | 01 자바스크립트개념 | hiwebs | 2014.04.01 |
[javascript] 기초강좌 | 02 산술, 대입, 증감, 비교연산자 | hiwebs | 2014.04.01 |
[javascript] 기초강좌 | 03 논리연산자, 비트, 삼항연산자, 기타연산자 | hiwebs | 2014.07.02 |
[javascript] 기초강좌 | 4장. 비교제어문(if문) | hiwebs | 2014.07.02 |