SlideShare a Scribd company logo
4
Most read
17
Most read
JAVASCRIPT 
1강 . 기본 문법
1. 기본용어 
2. 주석 
3. alert, 문자열, 숫자, 불 
4. 변수 
5. 복합대입 연산자 및 증감연산자 
6. 자료형 검사 
7. 입력 
8. 함수
1. 기본용어 
※표현식 : 자바스크립트에서 값을 만들어내는 간단 
한 코드 
하나이상의 표현식이 모여 문장을 이룸 
※키워드 : 특별한 의미가 있는 단어 프로그램작성시 
키워드 사용 
하지 않는 것을 권고 
구※분식별자 단독으로 사용 다른 식별자와 사 
용 
식별자 뒤에 괄호 
X 
변수 속성 
식별자 뒤에 괄호 
O 
ex) alert(“hello”) -> 함함수수 메서드 
Array.length -> 속성 
input -> 변수 
Math.abs(1) -> 메서드
2. 주석 
2-1 html 주석 
<html> 
<head> 
<! -- 주석 --> 
<script> 
</script> 
</head> 
2-2 javascript 주석 
<script> 
• // 주석문 or /* 주석문 */ 
</script>
3. alert, 문자열, 숫자, 불 
3-1 alert([String message]) 
alert() 함수를 사용하면 웹브라우저에 경고 
창을 띄울 수 있음 
3-2 
문자열 alert(“This is String”); 
숫자 alert(5+1) , alert((3+2)*3) 
불 alert(1>2) -> false반환 
alert(2>1) -> true 반환
3-3 비교연산자 
( >= , <=, >, <, ==, != ) 
3-4 논리 연산자 
( !, &&, || ) 
3-5 논리곱 연산자 
좌변 우변 결과 
True Ture Ture 
True False False 
False False False 
False False False 
3-6 논리합 연산자 
좌변 우변 결과 
True Ture Ture 
True False True 
False True True 
False False False
4. 변수 
- 값을 저장할 때 사용하는 식별자 
- 숫자 및 모든 자료형 저장 가능 
* var 식별자; 
<script> 
var pi = 3.14; 
alert(pi); 
</script> 
6가지 자료형 
<script> 
var stringVar = ‘String’; 
var numberVar = 111; 
var booleanVar = true; 
var functionVar = function() {}; 
var objectVar = {}; 
</script>
5. 복합대입연산자 및 증감 연산자 
5-1 복합대입연산자 
( +=, -+, *=, /=, %= ) 
var a = 10; 
a +=10; 
alert(a); 
출력값 : 20 
5-2 증감 연산자 
(변수++, ++변수, 변수--, --변수) 
var a= 10; 
alert(a++); 출력 값 : 10 
alert(++a); 출력 값 : 12 
alert(a--) 출력 값 : 12 
alert(--a); 출력 값 : 10
6. 자료형 검사 ( typeof ) 
alert(typeof(‘string’)); 
alert(typeof(‘244’); 
alert(typeof (true)); 
alert(tpyeof (function() {})); 
alert(tpyeof ({})); // ? 
alert(typeof (alpha)); 
6-1 undefined자료형 
<script> 
var variable; 
alert(typeof (variable)); 
</script>
7. 입력 
Prompt([String message], [String defaultValue]) : 
문자열을 입력할 때 
(숫자는 문자열을 입력받은후에 숫자료 변경해야함) 
<script> 
var input = prompt(‘Message’, ‘abc’); 
alert(input); 
confirm() : 불을 입력받을 때 
<script> 
var input = confirm(“수락하시겠습니까?”); 
alert(input); 
</script> 
확인 -> true리턴, 취소 -> false리턴
7-1 자료형변환 
숫자 자료형 변환 
<script> 
var input = prompt(‘숫자입력’, ‘숫자’); 
var numberInput = Number(input); 
alert(typeof (numberInput))+ ‘ : ‘ + 
numberInput); 
불 자료형 변환 
alert(Boolean(0)); 
alert(Boolean(NaN)); 
alert(Boolean(‘’));; 
alert(Boolean(null)); 
alert(Boolean(undefined)); 
모두 false로 변환 (나머지는 모두 true로 변 
환)
8. 일치 연산자 
비교연산자 사용시 문제 발생 
<script> 
alert(‘’ == false); 
alert(0 == false); 
alert(‘273’ == 273); 
</script> 
모두 true를 출력. 
자동으로 자료형 변환. 
*이러한 유연성 때문에 원하는 결과값 받지 
못하는 경우 발생 
확실한 구분을 짓기 위한 연산자 
(===, !==) 
<script> 
alert(‘’ === false); 
alert(0 === false); 
</script>
* 키워드 
break else instanceof true 
case false new try 
catch finally null typeof 
continue for return var 
default function switch void 
delete if this while 
do in throw with 
abstract double implements private 
throws boolean enum import 
protected transient byte export 
int public volatile char 
extends interface short class 
final long static const 
float native super debugger 
goto package synchronized
함수 
-선언적 함수 
function 함수(){ 
}; 
-가변인자함수 
<script> 
function sumALL(){ 
alert(typeof (argument) +' : ' + arguments.le 
ngth); 
} 
sumALL(1,2,3,4,5,6,7,8,9); 
</script>
- 내부함수 
function 외부함수(){ 
function 내부함수1(){ 
} 
function 내부함수2(){ 
} 
}
/* A가 만든 square함수 */ 
function square(x){ 
return x+x; 
} 
function a(w,h){ 
return Math.sqrt(square(w)+square(h)); 
} 
alert(a); 
/* B가 만든 square함수 */ 
function square(w,h,hy){ 
if() 
else() 
~~~~~~~~~~ 
} 
</script> 
<script> 
function a(w,h){ 
function square(x){ 
return x+x; 
} 
return Math.sqrt(square(w)+square(h)); 
} 
</script>
- 콜백함수 
함수를 매개변수로 넘겨줌. 
<script> 
function callTenTimes(callback){ // 함수를 매 
개변수로 받아 callback함수를 10번 실행하게 
됩니다. 
for(var i =0; i<10; i++) 
{ 
callback(); 
} 
} 
var callback() = function(){ 
alert('함수호출'); 
} 
callTenTimes(callback); // callTenTimes로 함 
수를 매개변수로 삼아 전달하고 있습니다. 
</script>

More Related Content

PPTX
Javascript 함수(function) 개념, 호출패턴, this, prototype, scope
PPTX
Javascript 실행 가능한 코드(Executable Code)와 실행 콘텍스트(Execution Context), Lexical En...
DOCX
Javascript 완벽 가이드 정리
PPTX
자바스크립트 함수
PDF
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
PPTX
자바스크립트 기초문법~함수기초
PDF
Javascript 교육자료 pdf
PPTX
스파르탄스터디 E04 Javascript 객체지향, 함수형 프로그래밍
Javascript 함수(function) 개념, 호출패턴, this, prototype, scope
Javascript 실행 가능한 코드(Executable Code)와 실행 콘텍스트(Execution Context), Lexical En...
Javascript 완벽 가이드 정리
자바스크립트 함수
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
자바스크립트 기초문법~함수기초
Javascript 교육자료 pdf
스파르탄스터디 E04 Javascript 객체지향, 함수형 프로그래밍

What's hot (20)

PDF
[2012 CodeEngn Conference 07] manGoo - Exploit Writing Technique의 발전과 최신 트랜드
PDF
[2013 CodeEngn Conference 08] manGoo - Windows 8 Exploit
PDF
2.Startup JavaScript - 연산자
PPTX
프론트엔드스터디 E03 - Javascript intro.
PPTX
Startup JavaScript 6 - 함수, 스코프, 클로저
PPTX
Startup JavaScript 3 - 조건문, 반복문, 예외처리
PPTX
골때리는 자바스크립트 발표자료
PPTX
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
PDF
[ES6] 4. Spread, Rest parameter
PPT
헷갈리는 자바스크립트 정리
PPT
호이스팅, 클로저, IIFE
PPTX
0.javascript기본(~3일차내)
PDF
1.Startup JavaScript - 프로그래밍 기초
PDF
Perl Script
PPTX
Angular2 가기전 Type script소개
PDF
6 function
PPTX
Startup JavaScript 8 - NPM, Express.JS
PPTX
Startup JavaScript 4 - 객체
PDF
14장 - 15장 예외처리, 템플릿
PDF
Tcpl 14장 예외처리
[2012 CodeEngn Conference 07] manGoo - Exploit Writing Technique의 발전과 최신 트랜드
[2013 CodeEngn Conference 08] manGoo - Windows 8 Exploit
2.Startup JavaScript - 연산자
프론트엔드스터디 E03 - Javascript intro.
Startup JavaScript 6 - 함수, 스코프, 클로저
Startup JavaScript 3 - 조건문, 반복문, 예외처리
골때리는 자바스크립트 발표자료
Startup JavaScript 5 - 객체(Date, RegExp, Object, Global)
[ES6] 4. Spread, Rest parameter
헷갈리는 자바스크립트 정리
호이스팅, 클로저, IIFE
0.javascript기본(~3일차내)
1.Startup JavaScript - 프로그래밍 기초
Perl Script
Angular2 가기전 Type script소개
6 function
Startup JavaScript 8 - NPM, Express.JS
Startup JavaScript 4 - 객체
14장 - 15장 예외처리, 템플릿
Tcpl 14장 예외처리
Ad

Similar to Javascript기초 (20)

PPTX
자바스크립트 기초
PDF
외계어 스터디 2/5 - Expressions & statements
PDF
처음배우는 자바스크립트, 제이쿼리 #1
PDF
Start IoT with JavaScript - 2.연산자
PPTX
Javascript introduction, dynamic data type, operator
PPT
ch04
PPTX
자바스크립트.
PPTX
You dont know_js
PDF
Javascript 101
PPTX
Javascript
PDF
Start IoT with JavaScript - 4.객체1
PDF
ES6 for Node.js Study
PDF
Intro to JavaScript - Week 1: Value, Type, Operator
PPTX
javascript 자료형
PDF
Javascript
PPTX
Javascript 박재은
PPTX
자바스크립트
PDF
키트웍스_발표자료_김경수functional_programming240920.pdf
PDF
PHP 사용하기
PDF
7주 JavaScript Part1
자바스크립트 기초
외계어 스터디 2/5 - Expressions & statements
처음배우는 자바스크립트, 제이쿼리 #1
Start IoT with JavaScript - 2.연산자
Javascript introduction, dynamic data type, operator
ch04
자바스크립트.
You dont know_js
Javascript 101
Javascript
Start IoT with JavaScript - 4.객체1
ES6 for Node.js Study
Intro to JavaScript - Week 1: Value, Type, Operator
javascript 자료형
Javascript
Javascript 박재은
자바스크립트
키트웍스_발표자료_김경수functional_programming240920.pdf
PHP 사용하기
7주 JavaScript Part1
Ad

Javascript기초

  • 1. JAVASCRIPT 1강 . 기본 문법
  • 2. 1. 기본용어 2. 주석 3. alert, 문자열, 숫자, 불 4. 변수 5. 복합대입 연산자 및 증감연산자 6. 자료형 검사 7. 입력 8. 함수
  • 3. 1. 기본용어 ※표현식 : 자바스크립트에서 값을 만들어내는 간단 한 코드 하나이상의 표현식이 모여 문장을 이룸 ※키워드 : 특별한 의미가 있는 단어 프로그램작성시 키워드 사용 하지 않는 것을 권고 구※분식별자 단독으로 사용 다른 식별자와 사 용 식별자 뒤에 괄호 X 변수 속성 식별자 뒤에 괄호 O ex) alert(“hello”) -> 함함수수 메서드 Array.length -> 속성 input -> 변수 Math.abs(1) -> 메서드
  • 4. 2. 주석 2-1 html 주석 <html> <head> <! -- 주석 --> <script> </script> </head> 2-2 javascript 주석 <script> • // 주석문 or /* 주석문 */ </script>
  • 5. 3. alert, 문자열, 숫자, 불 3-1 alert([String message]) alert() 함수를 사용하면 웹브라우저에 경고 창을 띄울 수 있음 3-2 문자열 alert(“This is String”); 숫자 alert(5+1) , alert((3+2)*3) 불 alert(1>2) -> false반환 alert(2>1) -> true 반환
  • 6. 3-3 비교연산자 ( >= , <=, >, <, ==, != ) 3-4 논리 연산자 ( !, &&, || ) 3-5 논리곱 연산자 좌변 우변 결과 True Ture Ture True False False False False False False False False 3-6 논리합 연산자 좌변 우변 결과 True Ture Ture True False True False True True False False False
  • 7. 4. 변수 - 값을 저장할 때 사용하는 식별자 - 숫자 및 모든 자료형 저장 가능 * var 식별자; <script> var pi = 3.14; alert(pi); </script> 6가지 자료형 <script> var stringVar = ‘String’; var numberVar = 111; var booleanVar = true; var functionVar = function() {}; var objectVar = {}; </script>
  • 8. 5. 복합대입연산자 및 증감 연산자 5-1 복합대입연산자 ( +=, -+, *=, /=, %= ) var a = 10; a +=10; alert(a); 출력값 : 20 5-2 증감 연산자 (변수++, ++변수, 변수--, --변수) var a= 10; alert(a++); 출력 값 : 10 alert(++a); 출력 값 : 12 alert(a--) 출력 값 : 12 alert(--a); 출력 값 : 10
  • 9. 6. 자료형 검사 ( typeof ) alert(typeof(‘string’)); alert(typeof(‘244’); alert(typeof (true)); alert(tpyeof (function() {})); alert(tpyeof ({})); // ? alert(typeof (alpha)); 6-1 undefined자료형 <script> var variable; alert(typeof (variable)); </script>
  • 10. 7. 입력 Prompt([String message], [String defaultValue]) : 문자열을 입력할 때 (숫자는 문자열을 입력받은후에 숫자료 변경해야함) <script> var input = prompt(‘Message’, ‘abc’); alert(input); confirm() : 불을 입력받을 때 <script> var input = confirm(“수락하시겠습니까?”); alert(input); </script> 확인 -> true리턴, 취소 -> false리턴
  • 11. 7-1 자료형변환 숫자 자료형 변환 <script> var input = prompt(‘숫자입력’, ‘숫자’); var numberInput = Number(input); alert(typeof (numberInput))+ ‘ : ‘ + numberInput); 불 자료형 변환 alert(Boolean(0)); alert(Boolean(NaN)); alert(Boolean(‘’));; alert(Boolean(null)); alert(Boolean(undefined)); 모두 false로 변환 (나머지는 모두 true로 변 환)
  • 12. 8. 일치 연산자 비교연산자 사용시 문제 발생 <script> alert(‘’ == false); alert(0 == false); alert(‘273’ == 273); </script> 모두 true를 출력. 자동으로 자료형 변환. *이러한 유연성 때문에 원하는 결과값 받지 못하는 경우 발생 확실한 구분을 짓기 위한 연산자 (===, !==) <script> alert(‘’ === false); alert(0 === false); </script>
  • 13. * 키워드 break else instanceof true case false new try catch finally null typeof continue for return var default function switch void delete if this while do in throw with abstract double implements private throws boolean enum import protected transient byte export int public volatile char extends interface short class final long static const float native super debugger goto package synchronized
  • 14. 함수 -선언적 함수 function 함수(){ }; -가변인자함수 <script> function sumALL(){ alert(typeof (argument) +' : ' + arguments.le ngth); } sumALL(1,2,3,4,5,6,7,8,9); </script>
  • 15. - 내부함수 function 외부함수(){ function 내부함수1(){ } function 내부함수2(){ } }
  • 16. /* A가 만든 square함수 */ function square(x){ return x+x; } function a(w,h){ return Math.sqrt(square(w)+square(h)); } alert(a); /* B가 만든 square함수 */ function square(w,h,hy){ if() else() ~~~~~~~~~~ } </script> <script> function a(w,h){ function square(x){ return x+x; } return Math.sqrt(square(w)+square(h)); } </script>
  • 17. - 콜백함수 함수를 매개변수로 넘겨줌. <script> function callTenTimes(callback){ // 함수를 매 개변수로 받아 callback함수를 10번 실행하게 됩니다. for(var i =0; i<10; i++) { callback(); } } var callback() = function(){ alert('함수호출'); } callTenTimes(callback); // callTenTimes로 함 수를 매개변수로 삼아 전달하고 있습니다. </script>