Access the HTML element with the specified id, and change its content: 지정된 ID를가진 HTML 요소에액세스하여그내용을변경할수있습니다. specified-특정한, specifiecation-사양 ( 예 ) 컴퓨터

Similar documents
PHP 로출력텍스트에는 echo 와 print 두가지기본문장이있습니다 In the example above we have used the echo statement to output the text "Hello World". 위의예에서우리는텍스트 "Hello World

Page 2 of 5 아니다 means to not be, and is therefore the opposite of 이다. While English simply turns words like to be or to exist negative by adding not,

Page 2 of 6 Here are the rules for conjugating Whether (or not) and If when using a Descriptive Verb. The only difference here from Action Verbs is wh

PowerPoint Template

step 1-1

강의10

var answer = confirm(" 확인이나취소를누르세요."); // 확인창은사용자의의사를묻는데사용합니다. if(answer == true){ document.write(" 확인을눌렀습니다."); else { document.write(" 취소를눌렀습니다.");

Javascript.pages

Hi-MO 애프터케어 시스템 편 5. 오비맥주 카스 카스 후레쉬 테이블 맥주는 천연식품이다 편 처음 스타일 그대로, 부탁 케어~ Hi-MO 애프터케어 시스템 지속적인 모발 관리로 끝까지 스타일이 유지되도록 독보적이다! 근데 그거 아세요? 맥주도 인공첨가물이

Modern Javascript

Output file

Columns 8 through while expression {commands} 예제 1.2 (While 반복문의이용 ) >> num=0

DIY 챗봇 - LangCon

제이쿼리 (JQuery) 정의 자바스크립트함수를쉽게사용하기위해만든자바스크립트라이브러리. 웹페이지를즉석에서변경하는기능에특화된자바스크립트라이브러리. 사용법 $( 제이쿼리객체 ) 혹은 $( 엘리먼트 ) 참고 ) $() 이기호를제이쿼리래퍼라고한다. 즉, 제이쿼리를호출하는기호

C# Programming Guide - Types

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

예제 1.1 ( 관계연산자 ) >> A=1:9, B=9-A A = B = >> tf = A>4 % 4 보다큰 A 의원소들을찾을경우 tf = >> tf = (A==B) % A

슬라이드 1

Introduction to Geotechnical Engineering II

- 2 -

Microsoft PowerPoint - ch03ysk2012.ppt [호환 모드]

OCW_C언어 기초

<B3EDB9AEC1FD5F3235C1FD2E687770>

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Stage 2 First Phonics

본문01

6자료집최종(6.8))

chap 5: Trees

C++-¿Ïº®Çؼ³10Àå

untitled

Microsoft PowerPoint - 27.pptx

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

untitled

10 강. 쉘스크립트 l 쉘스크립트 Ÿ 쉘은명령어들을연속적으로실행하는인터프리터환경을제공 Ÿ 쉘스크립트는제어문과변수선언등이가능하며프로그래밍언어와유사 Ÿ 프로그래밍언어와스크립트언어 -프로그래밍언어를사용하는경우소스코드를컴파일하여실행가능한파일로만들어야함 -일반적으로실행파일은다

PowerPoint Presentation

11¹Ú´ö±Ô

Microsoft Word - FunctionCall

Domino Designer Portal Development tools Rational Application Developer WebSphere Portlet Factory Workplace Designer Workplace Forms Designer

¹Ìµå¹Ì3Â÷Àμâ

Tcl의 문법

PowerPoint 프레젠테이션

#Ȳ¿ë¼®

<B3EDB9AEC1FD5F3235C1FD2E687770>

300 구보학보 12집. 1),,.,,, TV,,.,,,,,,..,...,....,... (recall). 2) 1) 양웅, 김충현, 김태원, 광고표현 수사법에 따른 이해와 선호 효과: 브랜드 인지도와 의미고정의 영향을 중심으로, 광고학연구 18권 2호, 2007 여름

Introduction- 소개 Previous- 이전, Next Chapter- 다음장 JavaScript is the most popular scripting language in the world. It is the standard language used in w

하나님의 선한 손의 도우심 이세상에서 가장 큰 축복은 하나님이 나와 함께 하시는 것입니다. 그 이 유는 하나님이 모든 축복의 근원이시기 때문입니다. 에스라서에 보면 하나님의 선한 손의 도우심이 함께 했던 사람의 이야기 가 나와 있는데 에스라 7장은 거듭해서 그 비결을

0125_ 워크샵 발표자료_완성.key

휠세미나3 ver0.4

Chapter 1

슬라이드 1

13주-14주proc.PDF

A Dynamic Grid Services Deployment Mechanism for On-Demand Resource Provisioning

2 min 응용 말하기 01 I set my alarm for It goes off. 03 It doesn t go off. 04 I sleep in. 05 I make my bed. 06 I brush my teeth. 07 I take a shower.

Microsoft PowerPoint - a10.ppt [호환 모드]

PHPoC vs PHP > 개요 개요 PHPoC 는솔내시스템 이자체개발한프로그래밍언어입니다. 당사의모든 PHPoC 제품들의펌웨어에는 PHPoC 인터프리터가내장되어있습니다. PHPoC 는범용스크립트언어인 PHP 를기반으로제작되었습니다. PHPoC 는매우간단하여 C 언어등

Visual Basic 반복문


歯M PDF


PowerPoint 프레젠테이션

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3

PowerPoint Presentation

2014 HSC Korean Continuers


Microsoft PowerPoint - chap06-2pointer.ppt

8장 문자열

퇴좈저널36호-4차-T.ps, page Preflight (2)

Microsoft PowerPoint - CHAP-03 [호환 모드]

Microsoft PowerPoint 세션.ppt

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Page 2 of 8 Here s how we can change the previous sentence to use honorific speech, to show extra respect to the father. 아버지가어디에계세요? Where s dad? Usin

Microsoft PowerPoint - ch07 - 포인터 pm0415

<31342D3034C0E5C7FDBFB52E687770>

DE1-SoC Board

슬라이드 1

_KF_Bulletin webcopy

#중등독해1-1단원(8~35)학

Microsoft PowerPoint Predicates and Quantifiers.ppt

목차 BUG 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG ROLLUP/CUBE 절을포함하는질의는 SUBQUE

저작자표시 - 비영리 - 변경금지 2.0 대한민국 이용자는아래의조건을따르는경우에한하여자유롭게 이저작물을복제, 배포, 전송, 전시, 공연및방송할수있습니다. 다음과같은조건을따라야합니다 : 저작자표시. 귀하는원저작자를표시하여야합니다. 비영리. 귀하는이저작물을영리목적으로이용할

<30322D28C6AF29C0CCB1E2B4EB35362D312E687770>

<3130C0E5>

1_2•• pdf(••••).pdf

쉽게

강의 개요

Journal of Educational Innovation Research 2017, Vol. 27, No. 2, pp DOI: : Researc

컴파일러

K7VT2_QIG_v3

1

example code are examined in this stage The low pressure pressurizer reactor trip module of the Plant Protection System was programmed as subject for

I&IRC5 TG_08권

장양수

04-다시_고속철도61~80p

슬라이드 1

슬라이드 제목 없음

4 CD Construct Special Model VI 2 nd Order Model VI 2 Note: Hands-on 1, 2 RC 1 RLC mass-spring-damper 2 2 ζ ω n (rad/sec) 2 ( ζ < 1), 1 (ζ = 1), ( ) 1

Something that can be seen, touched or otherwise sensed

<32382DC3BBB0A2C0E5BED6C0DA2E687770>

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2

Transcription:

How To A JavaScript is surrounded by a <script> and </script> tag. 자바스크립트는 <script> 와 </script> tag. 로둘러싸여있습니다. surrounde-에워싸다. JavaScript is typically used to manipulate HTML elements. 자바스크립트는일반적으로 HTML 요소를조작하는데사용됩니다. typical- 전형적인 The <script> Tag To insert a JavaScript into an HTML page, use the <script> tag. HTML 페이지에자바스크립트를삽입하려면 <script> tag 를사용합니다. into-~ 으로 The <script> and </script> tells where the JavaScript starts and ends. <script> 와 </script> 는자바스크립트가시작되고끝나는곳을알려줍니다. The lines between the <script> and </script> contain the JavaScript <script> 와 </script> 사이에는자바스크립트가포함 <script> alert("my First JavaScript"); </script> You don't have to understand the code above. Just take it for a fact, that the browser will interpret and execute the JavaScript code between the <script> and </script> tags. 당신은위의코드를이해할필요가없습니다. 그냥브라우저가 <SCRIPT> 와 </script> 태그사이의자바스크립트코드를해석하고실행할것입니다. Some examples have type="text/javascript" in the <script> tag. This is not required in HTML5. JavaScript is the default scripting language in all modern browsers and in HTML5. 몇가지예를입력 <script> tag에 = "text/javascript" 이것은 HTML5에필요하지않습니다. 자바스크립트는모든현대적인브라우저와 HTML5의기본스크립트언어입니다. Manipulating HTML Elements HTML 요소를조작 Manipulating- 조작하다, Elements- 요소 To access an HTML element from JavaScript, you can use the document.getelementbyid(id) method. 자바스크립트에서 HTML 요소에액세스하려면, 당신은 document.getelementbyid (id) 메소드를사용해야한다. attribute- 속성, identify- 확인, access- 접근하다. Use the "id" attribute to identify the HTML element "ID" 속성을사용하여 HTML 요소를식별한다.

Access the HTML element with the specified id, and change its content: 지정된 ID를가진 HTML 요소에액세스하여그내용을변경할수있습니다. specified-특정한, specifiecation-사양 ( 예 ) 컴퓨터사양 The JavaScript is executed by the web browser. In this case, the browser will access the HTML element with id="demo", and replace its content (innerhtml) with "My First JavaScript". 자바스크립트는웹브라우저에서실행됩니다. 이경우, 브라우저는 id = "demo" 로 HTML 요소에액세스하고, "My First JavaScript" 와그콘텐츠 (innerhtml) 를대체합니다. Writing to The Document Output 입력한문서를출력 Output- 출력 The example below writes a <p> element directly into the HTML document output: 아래의예는직접 HTML 문서출력으로 <P> 요소를글을참고 below-아래 Warning 경고 Use document.write() only to write directly into the document output. document.write() 문서출력에만사용하십시오.directly- 직접 If you execute document.write after the document has finished loading, the entire HTML page will be overwritten: 문서작성완료후 document.write를실행하면전체 HTML 페이지가덮어쓰기됩니다 overwritten-덮어쓰다

Where To A JavaScript can be put in the <body> and in the <head> section of an HTML page. 자바스크립트는 <body> 와 HTML 페이지의 <head> 섹션에넣어사용할수있습니다. put- 넣어, section- 구역 JavaScript in <body> <body> 안의자바스크립트 The example below manipulate the content of an existing <p> element when the page loads 아래의예는기존 <P> 요소의내용을조작할때실어서보내오는페이지이다 load-싣다, 적재 The JavaScript is placed at the bottom of the page to make sure it is executed after the <p> element is created. 자바스크립트는 <P> 요소가생성된후에실행되고있는지확인하기위해페이지의하단에배치됩니다 sure-확실한, placed-위치, bottom-바닥, 아래 JavaScript Functions and Events 자바스크립트함수및이벤트 The JavaScript statement in the example above, is executed when the page loads, but that is not always what we want. 자바스크립트문은위의예처럼페이지가자바스크립트를적재하여실행하지만우리가원하는걸항상그렇지는않습니다.

Sometimes we want to execute a JavaScript when an event occurs, such as when a user clicks a button. Then we can write the script inside a function, and call the function when the event occurs. 때때로우리는때자바스크립트를실행하려면이벤트가발생하는사용자가버튼을클릭할때등. 그럼우리가내부에스크립트를작성할수함수와이벤트가발생할때함수를호출하십시오. function-함수, occurs-발생, inside-내구, when-언제, Then -그래서 You will learn more about JavaScript functions and events in later chapters. 나중에챕터에서 JavaScript 함수및이벤트에대한자세한내용을배울것입니다. about- 많은, ~ 에대하여 A JavaScript Function in <head> <HEAD> 에있는자바스크립트함수 The example below calls a function in the <head> section when a button is clicked 아래의예는버튼을클릭하면 <head> 섹션에서함수를호출한다. A JavaScript Function in <body> This example also calls a function when a button is clicked, but the function is in the <body> 이도버튼을클릭하면함수를호출하지만, 함수는 <BODY> 안에있습니다. Scripts in <head> and <body> 스크립트안의 <head> 와 <body> You can place an unlimited number of scripts in your document, and you can have scripts in both the <body> and the <head> section at the same time.

귀하의문서에스크립트를무제한배치할수있습니다, 당신은같은시간에 <body> 및 <head> 섹션모두에서스크립트를 할수있습니다. unlimited- 무제한 It is a common practice to put functions in the <head> section, or at the bottom of the page. This way they are all in one place and do not interfere with page content. 이 <head> 섹션는기능을넣어, 또는페이지의아래쪽에하는것이일반적입니다. 이렇게한곳에서모두그들과페이지콘텐츠에영향을주지않습니다. Using an External JavaScript 외부자바스크립트를사용하여 External- 외부 Scripts can also be placed in external files. External files often contain code to be used by several different web pages. 스크립트는외부파일에배치할수있습니다. 외부파일은종종여러다른웹페이지에서사용하는코드가포함되어있습니다. External JavaScript files have the file extension.js. 외부자바스크립트파일은.js 라는파일확장자가있습니다. extension- 확장 To use an external script, point to the.js file in the "src" attribute of the <script> tag <script> 태그의 "SRC" 속성에 js 파일에외부스크립트지정하여사용하려면 point- 점, 지정하다 You can place the script in the <head> or <body> as you like. The script will behave as it was located exactly where you put the <script> tag in the document 당신이원한다면 <HEAD> 또는 <body> 태그에스크립트를넣을수있습니다. 이문서에 <script> 태그를넣어곳이정확한위치에스크립트가작동됩니다. located-위치, behave-~ 굴다 External scripts cannot contain <script> tags. 외부스크립트는 <script> 태그를포함할수없습니다.

Statements JavaScript is a sequence of statements to be executed by the browser. 자바스크립트는브라우저에의해실행되는문장의순서입니다. sequence-순서 JavaScript Statements 자바스크립트구문 JavaScript statements are "commands" to the browser. The purpose of the statements is to tell the browser what to do. 자바스크립트문은브라우저에 " 명령 " 입니다. 문장의목적은어떻게할브라우저를말하는것입니다. purpose-목적 This JavaScript statement tells the browser to write "Hello Dolly" inside an HTML element with id="demo 이자바스크립트문은 ID = "demo" 로 HTML 요소내에 "Hello Dolly ' 를쓸수있는브라우저를알려줍니다 document.getelementbyid("demo").innerhtml="hello Dolly"; Semicolon ; Semicolon separates JavaScript statements. 세미콜론은자바스크립트구문을분리합니다. Normally you add a semicolon at the end of each executable statement. 보통각실행문의끝에세미콜론을추가합니다. add- 추가 Using semicolons also makes it possible to write many statements on one line. 세미콜론을사용하면가능한한줄에여러문장을작성할수있습니다. Ending statements with semicolon is optional in JavaScript. You might see examples without semicolons. 세미콜론으로문장을종결하는것이자바스크립트에선택사항입니다. 당신은세미콜론없이예를볼수있습니다. JavaScript Code JavaScript code (or just JavaScript) is a sequence of JavaScript statements. 자바스크립트코드 ( 또는자바스크립트 ) 자바스크립트문장의순서입니다. just- 막 Each statement is executed by the browser in the sequence they are written. 각문은그들이기록된순서대로브라우저에의해실행됩니다. This example will manipulate two HTML elements: 이예는두 HTML 요소를조작합니다

JavaScript Code Blocks 자바스크립트코드블록 JavaScript statements can be grouped together in blocks. 자바스크립트문은블록에함께그룹화할수있습니다. Blocks start with a left curly bracket, and end with a right curly bracket. 블록은오른쪽으로물결브래킷과왼쪽물결브라켓의끝과시작합니다. The purpose of a block is to make the sequence of statements execute together. 블록의목적은문장의순서가함께실행하는것입니다. An good example of statements grouped together in blocks, are JavaScript functions. 블록이함께그룹화구문의좋은예는자바스크립트함수기능 This example will run a function that will manipulate two HTML elements 이예는두 HTML 요소를조작하는기능을실행합니다 You will learn more about functions in later chapters. 나중에챕터의기능에대해자세히배우게될것입니다. JavaScript is Case Sensitive JavaScript 는대소문자를구분 Sensitive- 민감한, 예민한 ( 여기서는대소문자를구별하는 ) JavaScript is case sensitive.

JavaScript 는대소문자를구분합니다. Watch your capitalization closely when you write JavaScript statements: 당신은자바스크립트문을쓸때대문자를주의해야한다. capitalization- 대문자 A function getelementbyid is not the same as getelementbyid. 함수 getelementbyid 는 getelementbyid 과동일하지않습니다 A variable named myvariable is not the same as MyVariable. 변수 myvariable 는 MyVariable 과동일하지않습니다. named- 이름 White Space 여백 JavaScript ignores extra spaces. You can add white space to your script to make it more readable. The following lines are equivalent 자바스크립트는공백을무시합니다. 당신은더읽을수있도록스크립트의다음줄에동일한공백을추가할수있습니다. equivalent-동등한, 같은, 상당한 var name="hege"; var name = "Hege"; Break up a Code Line 코드라인을끊기 Break= 깨뜨리다, 부수다, 끊다등 You can break up a code line within a text string with a backslash. The example below will be displayed properly: 당신은코드라인을끊을수있는텍스트문자열에서백슬래시와함께. 예를들어아래에올바르게표시됩니다 displayed-표시, properly-제대로, within-이내, below-아래 However, you cannot break up a code line like this 그러나이같은코드줄을끊을수없습니다. document.write \ ("Hello World!"); Comments 의견 JavaScript comments can be used to make the code more readable. 자바스크립트 comments 은코드가더읽기쉽게만들할수있습니다. readable- 판독할수있는 JavaScript Comments 자바스크립트의 Comments 는

Comments will not be executed by JavaScript. Comments 는자바스크립트가실행되지않습니다. Comments can be added to explain the JavaScript, or to make the code more readable. Comments 는자바스크립트를설명하거나코드를더읽기위해추가할수있습니다. Single line comments start with //. 한줄코멘트는 / / 로시작합니다. The following example uses single line comments to explain the code 다음는코드를설명하기위해한줄주석을사용합니다 following- 다음의, explain- 설명하다 JavaScript Multi-Line Comments 자바스크립트멀티라인코멘트 Multi line comments start with /* and end with */. 멀티라인주석은 */ 시작과 */ 로끝냅니다. The following example uses a multi line comment to explain the code: 다음는코드를설명하는여러줄주석을사용합니다 Using Comments to Prevent Execution 실행을방지할코멘트를사용한다. Prevent- 방지, 막다, 예방하다등

In the following example the comment is used to prevent the execution of one of the codelines (can be suitable for debugging): 다음에서는 comment가코드라인 ( 디버깅에적합할수있습니다 ) 중하나의실행을방지하기위해사용됩니다 suitable-적당한, debugging-디버깅 ( 버그를고치거나수정하는 ) In the following example the comment is used to prevent the execution of a code block (can be suitable for debugging) 다음예에서는주석이코드블록 ( 디버깅에적합할수있습니다 ) 의실행을방지하는데사용됩니다. Using Comments at the End of a Line 줄의끝에서코멘트를사용하여 In the following example the comment is placed at the end of a code line: 다음예에서는주석이코드라인의끝부분에배치됩니다

Variables Variables- 변수 Variables are "containers" for storing information 변수는정보를저장 " 컨테이너 " 입니다 storing- 저장, containers- 적재, 그릇 JavaScript Data Types 자바스크립트데이터유형 Like School Algebra 학교대수학처럼 Algebra- 대수학 Remember algebra from school? 학교에서대수을기억하십니까 Remember- 기억 x=5 y=6 z=x+y Do you remember that letters (like x) can be used to hold a value (like 5), and that you can use the information above to calculate the value of z to be 11?

당신은문자 (X) 를 (X = 5) 값을보유하는데사용할수있습니다, 그리고 11 이 Z 의값을계산하는위의정보를사용할수 있는것을기억하십니까? calculate- 계산하다, 의도하다 These letters are called variables, and variables can be used to hold values (x=5) or expressions (z=x+y). 이문자는호출되는변수와변수값 (X = 5) 또는표현을 (Z = X + Y) 표현하는데사용할수있습니다. expressions- 표현, hold- 보유 Think of variables as names or labels given to values. 이름이나값으로주어진레이블로변수를생각하십시오. label- 상표, 부호, 분류 JavaScript Variables 자바스크립트변수 As with algebra, JavaScript variables are used to hold values or expressions. 대수와마찬가지로, 자바스크립트변수값또는식을표현하는데사용됩니다. Variable can have a short names, like x and y, or more descriptive names, like age, sum, or, totalvolume. 변수는나이, 합계, 또는 totalvolume 같이 x 와 y, 또는좀더자세한설명이름처럼짧은이름을가질수있습니다. totalvolume- 총량 ( 모든개수 ) descriptive- 서술적인 JavaScript variables can also be used to hold text values, like: name="john Doe". name = "John Doe 같은자바스크립트변수도같은텍스트값을보유하는데사용할수있습니다 Here are the rules for JavaScript variable names 여기에자바스크립트변수이름에대한규칙은다음과같습니다 rules- 규칙 Variable names are case sensitive (y and Y are two different variables) 변수이름은대소문자를구분합니다 (y 와 Y 두개는다른변수입니다 ) Variable names must begin with a letter, the $ character, or the underscore character 변수이름은문자로시작해야하며, $ 또는 _ 이첫문자로사용될수없다 underscore- 밑줄, character- 문자, begin- 시작하다. Both JavaScript statements and JavaScript variables are case-sensitive. 자바스크립트문자및자바스크립트변수는모두대소문자를구분합니다. Declaring (Creating) JavaScript Variables (Creating) 자바스크립트변수선언 Declaring- 선언 Creating- 만들기 Creating a variable in JavaScript is most often referred to as "declaring" a variable. 변수를만드는방법은자바스크립트를변수를자주참조하여 " 선언 " 하는것이다. referred- 참조 You declare JavaScript variables with the var keyword: 당신은자바스크립트에서변수와 VAR 키워드를선언한다.

declare- 선언하다 var carname; After the declaration, the variable is empty (it has no value). 선언후, 변수는 ( 비어있는값 ) 비어있습니다. empty-빈, 없는, 비우다 To assign a value to the variable, use the equal sign: 변수에값을지정하려면등호를사용하여 equal- 같은, assign- 지정 sign- 기호, 등호 carname="volvo"; However, you can also assign a value to the variable when you declare it: 그러나당신이그것을선언할때는변수에값을할당할수있습니다 var carname="volvo"; In the example below we create a variable called carname, assigns the value "Volvo" to it, and put the value inside the HTML paragraph with id="demo": 아래의예에서우리는변수 carname을불러서거기에값 "Volvo" 를할당하고, ID = "demo" 로 HTML 문단내부의값을넣습니다. It's a good programming practice to declare all the variables you will need, in one place, at the beginning of your code. 이코드의시작부분에서, 한곳에서, 당신이필요한모든변수를선언하는좋은프로그래밍연습입니다. practice-연습 JavaScript Data Types 자바스크립트데이터유형 There are many types of JavaScript variables, but for now, just think of two types: text and numbers. 자바스크립트변수는다양한종류가있지만지금, 텍스트와숫자두종류가있다고생각해보자 When you assign a text value to a variable, put double or single quotes around the value. 당신이변수에텍스트값을지정하면, 이값주위에더블침대또는싱글따옴표를넣어. quotes- 인용부호

When you assign a numeric value to a variable, do not put quotes around the value. If you put quotes around a numeric value, it will be treated as text. 당신이변수에숫자값을지정하면, 이값주위에따옴표를넣지말아야합니다. 당신은숫자값주위에따옴표를입력하면, 그것은텍스트로취급됩니다. around 주위에 numeric-숫자 One Statement, Many Variables 한문장, 많은변수 You can declare many variables in one statement. Just start the statement with var and separate the variables by comma: 한문장에여러개의변수를선언할수있습니다. - 로문장을시작하고쉼표로변수를분리합니다. var name="doe", age=30, job="carpenter"; Your declaration can also span multiple lines 당신의선언은여러줄에걸칠수있습니다. span-기간, 걸치다 var name="doe", age=30, job="carpenter"; Value = undefined 값 = 정의되지않은 In computer programs, variables are often declared without a value. The value can be something that has to be calculated, or something that will be provided later, like user input. Variable declared without a value will have the value undefined. 컴퓨터프로그램에서변수는종종값없이선언됩니다. 이값은계산하는것을, 또는사용자입력과같은, 나중에제공될것입니다값없이선언된변수는정의되지않은무언가가될수있습니다 The variable carname will have the value undefined after the execution of the following statement: 변수 carname 는실행후정의되지않은다음과같은구문의값을주어야합니다. var carname; Re-Declaring JavaScript Variables 다시자바스크립트변수를선언한다. If you re-declare a JavaScript variable, it will not lose its value:. 당신은자바스크립트변수를다시선언하면그값을잃지않습니다. The value of the variable carname will still have the value "Volvo" after the execution of the following two statements: 변수의값 carname 은여전값다음두문장의실행후 "Volvo 를가지고있다. var carname="volvo"; var carname;

JavaScript Arithmetic 자바스크립트산술 Arithmetic 산수, 산술 As with algebra, you can do arithmetic with JavaScript variables, using operators like = and +: 대수와마찬가지로, 당신은 = 과 + 같은연산자를사용하여자바스크립트변수로산술을수행할수있다. Functions 함수 A function can be executed by an event, like clicking a button. 기능은버튼을클릭같은이벤트에의해실행할수있습니다. JavaScript Functions 자바스크립트함수 A function is a block of code that executes only when you tell it to execute. 함수는오직실행을원할경우에만실행코드블록입니다. It can be when an event occurs, like when a user clicks a button, or from a call within your script, or from a call within another function. 이이벤트가발생할때이될사용자가버튼을클릭할때, 또는스크립트내에서호출에서다른함수내에서호출을통해하실수있습니다. occurs-발생, another-다른 Functions can be placed both in the <head> and in the <body> section of a document, just make sure that the function exists, when the call is made. 함수의 <head> 와문서의 <body> 섹션에서호출하여함수가존재하는지확인한다. How to Define a Function 함수를정의하는방법

function functionname() { some code } The { and the } defines the start and end of the function. { 과 } 은시작과함수의끝을정의합니다. defines- 정의를내리다, 밝히다 Note: Do not forget about the importance of capitals in JavaScript! The word function must be written in lowercase letters, otherwise a JavaScript error occurs! Also note that you must call a function with the exact same capitals as in the function name. capitals-수도참고 : 자바스크립트에서대문자의중요성에대해잊지마세요! 함수는오직소문자로작성해야하며, 그렇지않으면자바스크립트오류가발생합니다. 또한함수이름과동일한수가있으면그함수를호출합니다. lowercase-소문자, otherwise-그렇지않으면, forget-잊다, importance-중요성, capitals-대문자 JavaScript Function 자바스크립트함수 The function is executed when the user clicks the button. 사용자가버튼을클릭할때함수가실행됩니다. You will learn more about JavaScript events in the JS Events chapter. 당신은 JS Events 장에서자바스크립트이벤트에대한자세한내용을배울수있습니다. Calling a Function with Arguments 인수와함수를호출 Arguments- 인수 When you call a function, you can pass along some values to it, these values are called arguments or parameters. 당신이함수를호출할때, 여기에인수또는매개변수및몇가지값을함께전달할수있습니다. along-함께, 데리고, parameters-매개변수 These arguments can be used inside the function.

이인수는함수내에서사용할수있습니다 You can send as many arguments as you like, separated by commas (,) 여러분이좋다면 (,) 쉼표로구분하여여러인자로보낼수있습니다. separated- 분리, send- 보내다 myfunction(argument1,argument2) Declare the argument, as variables, when you declare the function: 함수를선언할때, 변수로인수를선언 function myfunction(var1,var2) { some code } The variables and the arguments must be in the expected order. The first variable is given the value of the first passed argument etc. 변수는인수가예상하는순서에있어야합니다. 첫번째변수는첫번째전달인자등의값을주어집니다 expected-기대하는 order-순서, 주문, 명령 etc-~ 등 The function above will alert "Welcome Harry Potter, the Wizard" when the button is clicked. 위의함수는버튼을클릭하면 Welcome Harry Potter, the Wizard" 를알려줍니다. The function is flexible, you can call the function using different arguments, and different welcome messages will be given 함수가유연히동작하면, 당신은다른인자를사용하여함수를호출할수있으며, 다른환영메시지가제공됩니다 flexible-융통성있는, 유연한

The example above will alert "Welcome Harry Potter, the Wizard" or "Welcome Bob, the Builder" depending on which button is clicked. 위의예는클릭하는버튼에따라 " 환영해리포터의마법사 " 또는 " 환영밥, 빌더 " 를알려줍니다. Functions With a Return Value 함수와반환값 Sometimes you want your function to return a value back to where the call was made. 때때로당신의함수는곳으로값을반환하는함수를호출합니다. This is possible by using the return statement. 반환문을사용하여이것을가능하게합니다. When using the return statement, the function will stop executing, and return the specified value. return 문을사용하는경우이함수는실행중지하고지정된값을반환합니다. function myfunction() { var x=5; return x; } The function above will return the value 5. 위의함수는값 5를반환합니다. Note: It is not the entire JavaScript that will stop executing, only the function. JavaScript will continue executing code, where the function-call was made from. 참고 : 그것은단지함수만실행중지합니다. 함수호출로만든곳을자바스크립트코드를계속실행하고전체자바스크립트가중지되지않습니다.. The function-call will be replaced with the returnvalue: 함수호출은 returnvalue 으로대체될것이다 var myvar=myfunction(); The variable myvar holds the value 5, which is what the function "myfunction()" returns. 변수 myvar 가 5 라는값을가지고함수 "myfunction () 는 " 어떤함수를반환한다. You can also use the returnvalue without storing it as a variable: 당신은또한변수로저장하지않고 returnvalue 를사용할수있습니다

document.getelementbyid("demo").innerhtml=myfunction(); The innerhtml of the "demo" element will be 5, which is what the function "myfunction()" returns. "demo" 요소의 innerhtml 는함수 "myfunction () 가 "5 를반환할것이다. You can make a returnvalue based on arguments passed into the function: 당신은함수로전달되는인자에따라 returnvalue 할수있습니다 The return statement is also used when you simply want to exit a function. The return value is optional: 당신은단순히기능을종료할때 return 문은사용됩니다. 반환값은선택사항입니다 optional- 선택, simply- 단순히, 간간히 function myfunction(a,b) { if (a>b) { return; } x=a+b } The function above will exit the function if a>b, and will not calculate the sum of a and b. a>b인경우위의함수를종료합니다그리고 a와b의합을계산하지않습니다. calculate-계산 Local JavaScript Variables 지역자바스크립트변수 A variable declared (using var) within a JavaScript function becomes LOCAL and can only be accessed from within that function. (the variable has local scope). 자바스크립트함수내에서 (VAR를사용하여 ) 선언변수는될 LOCAL 만그함수내에서액세스할수있습니다. ( 변수는지역범위에있습니다.) becomes-된다. You can have local variables with the same name in different functions, because local variables are only recognized by the function in which they are declared. 지역변수만그들이선언되어있는함수에의해인정되고있기때문에, 다른기능에동일한이름을가진지역변수를가질

수있습니다. recognized- 인정하는 Local variables are deleted as soon as the function is completed. 지역변수는즉시함수가완료되면곧삭제됩니다. soon= 곧 Global JavaScript Variables 글로벌자바스크립트변수 Variables declared outside a function, become GLOBAL, and all scripts and functions on the web page can access it. 변수는함수외부에서선언될 GLOBAL, 웹페이지의모든스크립트및함수에액세스할수있습니다. outside-외부 The Lifetime of JavaScript Variables 자바스크립트변수의수명 Lifetime- 수명, 일생 The lifetime JavaScript variables starts when they are declared. 그들이선언을시작하면자바스크립트계속변수를실행한다. Local variables are deleted when the function is completed. 함수가완료될때지역변수는삭제됩니다. Global variables are deleted when you close the page. 당신이페이지를닫을때전역변수가삭제됩니다 Assigning Values to Undeclared JavaScript Variables 선언하지않은자바스크립트변수에값을할당 If you assign a value to variable that has not yet been declared, the variable will automatically be declared as a GLOBAL variable. 당신이아직선언되지않은변수에값을할당하면 GLOBAL 변수가자동으로선언됩니다 automatically-자동적으로 This statement: 이문장은 carname="volvo"; will declare the variable carname as a global variable, even if it is executed inside a function. carname 를이함수내에서실행되는경우에도전역변수로변수를선언합니다 Data Type String, Number, Boolean, Array, Object, Null, Undefined. 문자열, 숫자, 논리값, 배열, 객체, Null 값, 정의되지않음. JavaScript Strings

자바스크립트문자열 A string is a variable which stores a series of characters like "John Doe". 문자열은 "John Doe" 같은문자의일련의문자를저장하는변수입니다. series- 시리즈, 일련, 세트 A string can be any text inside quotes. You can use simple or double quotes 문자열은인용부호안에텍스트가들어갈수있습니다. 당신은간단한또 는큰따옴표를사용할수있습니다 double quotes- 큰따옴표 var carname="volvo XC60"; var carname='volvo XC60'; You can use quotes inside a string, as long as they don't match the quotes surrounding the string: 당신은문자열이인용부호로둘러싸지않는한문자열안에따옴표를사용할수있습니다 var answer="it's alright"; var answer="he is called 'Johnny'"; var answer='he is called "Johnny"'; Or you can put quotes inside a string by using the \ escape character: \ 이스케이프를사용하여문자열안에따옴표를넣을수있습니다 You can access each characters in a string with [position]: 당신은문자열의각문자에 [position] 와문자열을액세스할수있습니다 var character=carname[7]; String indexes are zero-based, which means the first character is [0], the second is [1], and so on. 문자열인덱스는 0 기반이며, 첫문자는 [0] 을이며, 두번째문자는 [1] 을의미합니다. based-기초, 기반 means-방법 JavaScript Numbers 자바스크립트번호

JavaScript has only one type of number. 자바스크립트는하나의숫자유형이있습니다. Numbers can be with, or without decimals: 숫자는소수점과함께, 또는소수점없이할수있습니다. decimals- 소수점 var pi=3.14; var x=34; The maximum number of decimals is 17. 소수점의최대수는 17입니다. Extra large or extra small numbers can be written with scientific notation: 특대또는추가적인작은숫자는과학적표기법으로기록할수있습니다 extra- 여분의, 추가 Extra large- 특대 scientific- 과학적인 notation- 표기법 written- 기록, 쓴 var y=123e5; // 12300000 var z=123e-5; // 0.00123 JavaScript arithmetic is not 100% accurate: 자바스크립트산술은 100 % 정확하지않습니다 : JavaScript Booleans 자바스크립트논리값 Booleans- 논리값 Booleans can have only two values: true or false. 참또는거짓 : 논리값은두값을가질수있습니다. var x=true var y=false Booleans are often used in conditional testing. You will learn more about conditional testing in a later chapter of this tutorial. Booleans는종종조건부테스트에사용됩니다. 당신은이튜토리얼이후조건부테스트에대한자세한내용을배울수있습니다.

JavaScript Arrays 자바스크립트배열 Arrays- 배열 The following code creates an Array called cars: 다음코드는자동차라는배열을생성합니다 var cars=new Array(); cars[0]="saab"; cars[1]="volvo"; cars[2]="bmw"; or (condensed array): 또는 ( 압축배열 ) condensed- 농축, 압축 var cars=new Array("Saab","Volvo","BMW"); or (literal array): 또는 ( 문자배열 ) var cars=["saab","volvo","bmw"]; Array indexes are zero-based, which means the first item is [0], second is [1], and so on. 배열인덱스는 0 기반이며, 이는첫번째항목은 [0] 을의미, 두번째는 [1] 을의미합니다. JavaScript Objects 자바스크립트객체 An object is delimited by curly braces. Inside the braces the object's properties are defined as name and value pairs (name : value). The properties are separated by commas: 객체는중괄호로구분합니다. (name : value) 괄호안에있는객체의속성이이름과값두개로 (name : value) 정의됩니다. 속성은쉼표로구분됩니다. properties-등록 delimited-구분 curly braces-중괄호 var person={firstname:"john", lastname:"doe", id:5566}; The object (person) in the example above has 3 properties: firstname, lastname, and id. 위의예에서객체 ( 사람은 ) 세속성을갖고있습니다. (firstname, lastname, and id) Spaces and line breaks are not important. Your declaration can span multiple lines 공백줄바꿈은당신의선언에여러줄에걸쳐중요하지않습니다. var person={ firstname : "John", lastname : "Doe", id : 5566 }; You can address the object properties in two ways: 당신은두가지방법으로개체속성을해결할수있습니다

Null or Undefined null 이거나정의되지않음 Non-existing is the value of a variable with no value. 존재하지않는값이없는변수의값입니다. Non-existing- 존재하지않는 Variables can be emptied by setting the value to null; 변수는값을넣을수도넣지않을수도있다. cars=null; person=null; Declaring Variable Types 변수유형을선언 When you declare a new variable, you can declare its type using the "new" keyword: 당신이새로운변수를선언할때, 당신은 " 새로운 " 키워드를사용하여유형을선언할수있다. var carname=new String; var x= new Number; var y= new Boolean; var cars= new Array; var person= new Object; All variables are objects. When you declare a new variable you create a new object. 모든변수는개체입니다. 당신이새로운변수를선언할때당신은새개체를만들수있습니다. Almost- 모든 Objects 객체 Almost everything in JavaScript is an Object: String, Number, Array, Function... 자바스크립트는거의모든것이객체입니다 : 문자열, 숫자, 배열, 함수... 등

In addition, JavaScript allows you to define your own objects. 또한, 자바스크립트는자신의개체를정의할수있습니다. addition- 부가 allows-~ 할수 JavaScript Objects 자바스크립트객체 JavaScript has several built-in objects, like String, Date, Array, and more. 자바스크립트는문자열과같은, 날짜, 배열등여러내장객체를가지고있습니다. several- 몇몇의 An object is just a special kind of data, with properties and methods. 객체는데이터의단지특별한프로퍼티와메소드의종류가있습니다. Objects Properties 객체속성 Properties are the values associated with an object. 속성은개체와연관된값입니다. associated- 관련 The syntax for accessing the property of an object is: 개체의속성을액세스하는구문은다음과같습니다 syntax- 구문 objectname.propertyname This example uses the length property of the String object to find the length of a string: 이는문자열의길이를찾기위해 String 개체가 length 속성을사용합니다 var message="hello World!"; var x=message.length; The value of x, after execution of the code above will be: X의값은, 코드의실행후위의것입니다. 12 Real Life Illustration 실제생활일러스트 A person is an object. 사람은하나의객체입니다. The persons' properties include name, height, weight, age, skin tone, eye color, etc. 사람의속성은이름, 신장, 체중, 연령, 피부톤, 눈색깔등을포함하고있다. All persons have these properties, but the values of those properties differ from person to person. 모든사람은이러한속성을가지고있지만, 그속성의값은사람마다다릅니다. differ- 다르다

Objects Have Methods 객체를가지는메소드 Methods are the actions that can be performed on objects. 메소드는객체를움직여수행하게할수있는작업입니다 actions- 행동 You can call a method with the following syntax: 다음과같은구문으로메소드를호출할수있습니다 objectname.methodname() This example uses the touppercase() method of the String object, to convert a text to uppercase: 이에서는대문자로텍스트를변환하려면 String 개체의 touppercase () 메소드를사용 var message="hello world!"; var x=message.touppercase(); The value of x, after execution of the code above will be: X의값은, 코드의실행후위의것입니다 HELLO WORLD! Real Life Illustrated 현실은그림 A person is an object. 사람은하나의객체입니다. The persons' methods could be eat(), sleep(), work(), play(), etc. 사람의속성은 eat(), sleep(), work(), play() 가있다. All persons have these methods. 모든사람이메소드를가지고있습니다. Creating JavaScript Objects 자바스크립트객체만들기 With JavaScript you can define and create your own objects. 자바스크립트를사용하면자신의개체를정의하고만들수있습니다. There are 2 different ways to create a new object: 새개체를만드는 2 가지방법이있습니다 1. Define and create a direct instance of an object. 1. 객체의인스턴스를직접정의및생성한다 2. Use a function to define an object, then create new object instances. 2. 객체를정의할수있는기능을사용하여다음새개체인스턴스를만들수있습니다. Creating a Direct Instance 직접인스턴스만들기

This example creates a new instance of an object, and adds four properties to it: 이에서는개체의새인스턴스를생성하고, 에 4 개의속성을추가합니다 personobj=new Object(); personobj.firstname="john"; personobj.lastname="doe"; personobj.age=50; personobj.eyecolor="blue"; Alternative syntax (using object literals): 대체문법 ( 객체문자를사용하여 ) Alternative-대체 Using an Object Constructor 개체생성자를사용하여 This example uses a function to construct the object: 이는객체를생성하는함수를사용하여 The reason for all the "this" stuff is that you're going to have more than one person at a time (which person you're dealing with must be clear). That's what "this" is: the instance of the object at hand. 손에있는객체의인스턴스는모든 ' 이 ' 거그이유는한번에하나이상의사람을봐야한다는것입니다 ( 당신이상대하고있는사람은명확하게해야합니다 ) 그래서 " 이 " 가무엇인지다음과같습니다 stuff-재료 Adding Methods to JavaScript Objects

자바스크립트객체에메소드를추가 Methods are just functions attached to objects. 메소드는객체에부착된기능입니다. attached- 첨부 Defining methods to an object is done inside the constructor function: 객체에메소드를정의는생성자함수내에서수행됩니다 function person(firstname,lastname,age,eyecolor) { this.firstname=firstname; this.lastname=lastname; this.age=age; this.eyecolor=eyecolor; this.changename=changename; function changename(name) { this.lastname=name; } } The changename() function assigns the value of name to the person's lastname property. changename () 함수는그사람의성속성이름의값을할당합니다. JavaScript knows which person you are talking about by "substituting" this with mymother. 자바스크립트는 " 대체 " 로이야기하는사람과 mymother 를함께알고있다. Creating JavaScript Object Instances 자바스크립트객체인스턴스만들기 Once you have a object constructor, you can create new instances of the object, like this: 당신은객체생성자가완료되면, 이같은개체의새인스턴스를만들수있습니다. constructor- 건설자 var myfather=new person("john","doe",50,"blue"); var mymother=new person("sally","rally",48,"green");

Adding Properties to JavaScript Objects 자바스크립트객체에속성을추가 You can add new properties to an existing object by simply giving it a value. 당신은단순히그것을값을제공하여기존개체에새속성을추가할수있습니다 existing- 현존하는 Assume that the personobj already exists - you can give it new properties named firstname, lastname, age, and eyecolor as follows: personobj이이미존재한다고가정합니다 - 당신은그것을다음과같은새로운 FirstName이명명속성, 성, 연령, eyecolor을제공할수있습니다. personobj.firstname="john"; personobj.lastname="doe"; personobj.age=30; personobj.eyecolor="blue"; x=personobj.firstname; The value of x, after execution of the code above will be: X 의값은, 코드의실행후위의것입니다 John Operations = is used to assign values. = 는값을할당하는데사용됩니다. + is used to add values. + 는값을추가하는데사용됩니다. The assignment operator = is used to assign values to JavaScript variables. 할당연산자 = 는자바스크립트변수에값을할당하는데사용됩니다. The arithmetic operator + is used to add values together. 산술연산자 + 는함께값을추가하는데사용됩니다.

JavaScript Arithmetic Operators 자바스크립트산술연산자 Arithmetic operators are used to perform arithmetic between variables and/or values. 산술연산자는변수및 / 또는값사이의산술을수행하는데사용됩니다. Given that y=5, the table below explains the arithmetic operators: 그것을감안할때 Y = 5 : 아래표는산술연산자를설명합니다 JavaScript Assignment Operators 자바스크립트할당연산자 Assignment operators are used to assign values to JavaScript variables. 할당연산자는자바스크립트변수에값을할당하는데사용됩니다. Given that x=10 and y=5, the table below explains the assignment operators: 그점을감안할때 X = 10 및 Y = 5, 표아래의할당연산자를설명합니다 The + Operator Used on Strings 문자열에사용되는 + 연산자 The + operator can also be used to add string variables or text values together. + 연산자도함께문자열변수또는텍스트값을추가하는데사용할수있습니다

To add a space between the two strings, insert a space into one of the strings 두문자열사이에공백을추가하려면, 문자열중하나에공간을삽입 or insert a space into the expression: 또는표현에공간을삽입 Adding Strings and Numbers 문자열과숫자추가 Adding two numbers, will return the sum, but adding a number and a string will return a string: 두숫자를추가하면, 합계를반환합니다하지만번호와문자열을추가하는것은문자열을반환합니다

Comparison Operators 비교연산자 Comparison- 비교 Operators- 연산자 Comparison and Logical operators are used to test for true or false. 비교및논리연산자의맞는지혹은틀린지를테스트하는데사용됩니다 true or false- 진실혹은거짓 Comparison Operators 비교연산자 Comparison operators are used in logical statements to determine equality or difference between variables or values. 비교연산자는변수또는값사이의평등한차이를결정하는논리구문에사용됩니다. equality-평등 logical statement-논리적인문장 Given that x=5, the table below explains the comparison operators: 점을감안할때 X = 5, 아래의표는비교연산자를설명합니다 explains- 설명 How Can it be Used 어떻게사용할수있는가 Comparison operators can be used in conditional statements to compare values and take action depending on the result 비교연산자는값을비교하고그에따라조치를취조건부문에서사용할수있습니다 depending-따라 conditional-조건부의 result- if (age<18) x="too young"; You will learn more about the use of conditional statements in the next chapter of this tutorial. 당신은이튜토리얼의다음장에서조건부진술의사용에대한자세한내용을배울수있습니다 Logical Operators 논리연산자 Logical operators are used to determine the logic between variables or values. JavaScript 는일부조건에따라변수에값을할당하는조건연산자가포함되어있습니다 determine- 결정

Given that x=6 and y=3, the table below explains the logical operators: 점을감안할때 X = 6 와 y = 3, 아래표는논리연산자를설명합니다 Conditional Operator 조건부연산자 Conditional- 조건부의, ~ 을조건으로한 JavaScript also contains a conditional operator that assigns a value to a variable based on some condition. JavaScript 는일부조건에따라변수에값을할당하는조건연산자가포함되어있습니다 variablename=(condition)?value1:value2 If...Else 만약... 아니면 If- 만일, 만약 Else- 그밖에, 그렇지않으면 Conditional statements are used to perform different actions based on different conditions. 조건부진술은여러조건에따라서로다른작업을수행하는데사용됩니다. perform- 수행 based- 기준 Conditional Statements 조건부문장 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this. 매우자주코드를작성하면다른결정에대해서로다른작업을수행하고합니다. 당신은이작업을수행하는코드에서조건구문을사용할수있습니다. In JavaScript we have the following conditional statements: 자바스크립트에서우리는다음과같은조건문장이있습니다

if statement - use this statement to execute some code only if a specified condition is true if 문 - 지정된조건이참인경우에만일부코드를실행하려면이문을사용 if...else statement - use this statement to execute some code if the condition is true and another code if the condition is false if...else 문 - 조건이사실과다른코드경우조건이거짓인경우일부코드를실행하려면이문을사용 if...else if...else statement - use this statement to select one of many blocks of code to be executed if...else if...else 문 - 실행하는코드의여러블록중하나를선택하려면이문을사용 switch statement - use this statement to select one of many blocks of code to be executed switch 문 - 실행하는코드의여러블록중하나를선택하려면이문을사용 If Statement if 문 Use the if statement to execute some code only if a specified condition is true. 지정된조건이참인경우에만문이몇가지코드를실행하는경우사용합니다 if (condition) { code to be executed if condition is true } Note that if is written in lowercase letters. Using uppercase letters (IF) will generate a JavaScript error! 위의경우는소문자로작성된것입니다. 대문자 (IF) 를사용하면자바스크립트오류를생성합니다 generate-생성 Notice that there is no..else.. in this syntax. You tell the browser to execute some code only if the specified condition is true. 만약이구문이없을경우당신의브라우저는오직지정된조건이참인경우에만일부코드를실행합니다. If...else Statement If...else 문

Use the if...else statement to execute some code if a condition is true and another code if the condition is not true. if...else 를사용하여문장이조건에해당하지않을경우다른조건의일부코드를실행합니다. if (condition) { code to be executed if condition is true } else { code to be executed if condition is not true } If...else if...else Statement If...else if...else 문 Use the if...else if...else statement to select one of several blocks of code to be executed. if...else if...else 를사용하여조건이사실과다른코드거나다른문이조건에해당하지않을경우 다 일부코드를실행합니 if (condition1) { code to be executed if condition1 is true } else if (condition2) { code to be executed if condition2 is true } else { code to be executed if neither condition1 nor condition2 is true }

switch 스위치 The switch statement is used to perform different action based on different conditions. switch 문은여러조건에따라서로다른작업을수행하는데사용됩니다 The JavaScript Switch Statement 자바스크립트스위치문 Use the switch statement to select one of many blocks of code to be executed. 실행하는코드의여러블록중하나를선택하는스위치문을사용합니다. switch(n) { case 1: execute code block 1 break; case 2: execute code block 2 break; default: code to be executed if n is different from case 1 and 2 } This is how it works: First we have a single expression n (most often a variable), that is evaluated once. The value of the expression is then compared with the values for each case in the structure. If there is a match, the block of code associated with that case is executed. Use break to prevent the code from running into the next case automatically. 이작동방법은다음과같습니다처음에우리는하나의표현이 N 번평가 ( 가장자주변수 ). 표현식의값은다음구조의각각의경우에대한값으로비교됩니다. 일치가있는경우, 해당사건과관련된코드블록이실행됩니다. 사용하다가자동으로다음경우에실행코드를방지할수있습니다.

The default Keyword 기본키워드 Use the default keyword to specify what to do if there is no match 일치하지않는경우기본키워드를사용하여지정하는가 Popup Boxes 팝업박스 JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box. 자바스크립트에는 3 가지의 popup boxes 가있다.-Alert box, Confirm box, and Prompt box Alert- 경고 Confirm- 확인 Prompt- 일러주다, 알려주다 kind of-~ 가지 Alert box

경고상자 An alert box is often used if you want to make sure information comes through to the user. 당신이원하는경우경고상자는사용자를통해확인정보를자주사용될수있다. through- 를통해 When an alert box pops up, the user will have to click "OK" to proceed. 경고상자가팝업되면사용자는계속진행하려면 "OK" 를클릭해야합니다 proceed- 진행 alert("sometext"); Confirm Box 확인상자 A confirm box is often used if you want the user to verify or accept something. 당신은사용자가무언가를확인하거나수락할경우확인상자가자주사용됩니다 verify- 확인 accept- 동의 When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. 확인상자가팝업되면, 사용자는다음단계로진행 " 확인 " 또는 " 취소 " 중하나를클릭해야합니다. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false. 사용자가 "OK" 를클릭하면상자가 true 를반환합니다. 사용자가 ' 취소 ' 를클릭하면상자가 false 를반환합니다. confirm("sometext");

Prompt Box 알림상자 A prompt box is often used if you want the user to input a value before entering a page. 당신은사용자가입력하는페이지를입력하기전에값을원하는경우메시지상자가자주사용됩니다 entering- 입력 When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value. 메시지상자가팝업되면사용자가입력값을입력한후다음단계로진행 " 확인 " 또는 " 취소 " 중하나를클릭해야합니다. If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null. 사용자가 "OK" 클릭하면상자는입력값을반환합니다. 사용자가 " 취소 " 를클릭하면상자는 null 반환합니다. prompt("sometext","defaultvalue"); Line Breaks To display line breaks inside a popup box, use a back-slash followed by the character n. For Loop 줄바꿈 For Loops will execute a block of code a specified number of times. 팝업상자안에줄바꿈을표시하려면 \ 와 n 을 (\n) 사용합니다

JavaScript Loops 자바스크립트의루프 For Loops will execute a block of code a specified number of times. 루프의경우시간지정숫자코드블록을실행합니다. Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use loops to perform a task like this. 종종코드를작성하면서코드의동일한부분이끝나지않고실행할수있습니다. 우리는이같은작업을수행하기위해루프를사용할수있습니다. 대신스크립트의여러거의같은라인을추가합니다. In JavaScript, there are two different kind of loops: 자바스크립트에서루프의두가지종류가있습니다 for - loops through a block of code a specified number of times for - 코드블록을통해루프지정된시간 while - loops through a block of code while a specified condition is true while - 지정된조건이참인동안코드블록을통해루프 The for Loop 루프에대해 The for loop is used when you know in advance how many times the script should run. 이스크립트가실행되어야횟수를사전에알게되면, 루프가사용됩니다 advance- 전진, 사전에 for (variable=startvalue;variable<endvalue;variable=variable+increment) { code to be executed } The example below defines a loop that starts with i=0. The loop will continue to run as long as i is less than 5. i will increase by 1 each time the loop runs. 아래의예는 i=0로시작하는루프를정의합니다. 루프만큼계속실행됩니다 5 미만일때 I = 1 루프가실행될때마다증가

합니다. Note: The increment parameter could also be negative, and the < could be any comparing statement. 참고 : 증가매개변수는음수가될수있으며, < 어떤비교진술할수있다. While Loop While Loops execute a block of code as long as a specified condition is true. 지정된조건이참일경우에만루프에한해코드블록을실행한다. The while loop loops through a block of code while a specified condition is true. 지정된조건이사실인경우코드블록을통해 while 루프가실행합니다. while (variable<endvalue) { code to be executed } Note: The < could be any comparing operator. < 어떤비교연산자를할수있습니다. The example below defines a loop that starts with i=0. The loop will continue to run as long as i is less than 5. i will increase by 1 each time the loop runs: 아래의는 i = 0 로시작하는루프를정의합니다. I 가 5 미만일경우. I = 1 루프가 5 가될때까지증가합니다

Note: Do not forget to increase the i variable used in the condition, otherwise i will always be less than 5, and the loop will never end! 증가하는것을잊지마세요 i의조건에서사용되는변수를, 그렇지않으면 i는항상 5 이상이어야하며, 루프가종료하지않습니다! The do...while Loop do...while Loop 문 The do...while loop is a variant of the while loop. This loop will execute the block of code once, before checking if the condition is true, then it will repeat the loop as long as the condition is true. do...while loop문은 while 루프의변형입니다. 이루프는조건이참인경우조건이사실로그때는오랫동안루프를반복해야합니다확인하기전에한번코드블록을실행합니다. do { code to be executed } while (variable<endvalue); The example below uses a do...while loop. The do...while loop will always be executed at least once, even if the condition is false, because the statements are executed before the condition is tested: 아래의는 do를사용하여 do...while loop. 조건이거짓인경우에도조건이테스트되기전에문이실행되기때문에루프는항상, 적어도한번이상은실행됩니다.

Note: Do not forget to increase the i variable used in the condition, otherwise i will always be less than 5, and the loop will never end! 증가하는것을잊지마세요 i의조건에서사용되는변수를, 그렇지않으면 i는항상 5 이상이어야하며, 루프가종료하지않습니다! Break Loop break Loop 문 The break Statement break 문 The break statement will break the loop and continue executing the code that follows after the loop (if any). break 문은루프를해제하고루프 ( 있는경우 ) 후다음코드를실행계속됩니다. The continue Statement continue 문 continue- 계속 The continue statement will break the current iteration and continue the loop with the next value. continue 문은현재의반복을해제하고다음값을루프를계속합니다.

For...In JavaScript For...In Statement 자바스크립트 For...In 문 The for...in statement loops through the properties of an object. For...In 문개체의속성을통해문루프인치 for (variable in object) { code to be executed } Note: The block of code inside of the for...in loop will be executed once for each property. 내부코드의블록에 for...in 루프의각속성에대해한번실행됩니다. Looping through the properties of an object: 개체의속성을통해반복