edubun 한국어

What programming is

A program is a list of instructions, and JavaScript carries them out one statement at a time, from the top line to the bottom.

Instructions a computer can follow

A recipe says "crack two eggs, whisk them, pour them into the pan." A person reading it fills in a lot on their own: which bowl to use, how hard to whisk, what to do if a piece of shell falls in. A computer fills in nothing. It does exactly what the instructions say, in exactly the order they are written, and it stops with an error the moment an instruction makes no sense to it. Programming is the work of writing instructions precise enough for a machine to follow.

Those instructions are written in a programming language. A programming language has a small vocabulary and strict grammar, so that every line means one thing and only one thing. This course uses JavaScript. It is the language built into every web browser, which means you already have everything you need to run it: the practice boxes on these pages run your code right inside the browser you are reading with. JavaScript also runs outside browsers, in tools such as Node.js, and the basics you learn here work the same way there.

Your first line of code

Almost every programming course starts by making the computer print a message. In JavaScript that looks like this:

console.log("Hello, world!");

Read it piece by piece. console is the place where a program writes messages for the person running it. .log means "write one line there." The parentheses hold what should be written, and the double quotes mark Hello, world! as text rather than as more code. The semicolon at the end closes the instruction, the way a full stop closes a sentence. One complete instruction like this is called a statement. When it runs, the console shows a single line: Hello, world! The quotes are not printed. They only tell JavaScript where the text starts and ends.

Top to bottom, one statement at a time

A program with several statements runs them in order. The second line does not start until the first has finished. The program below prints three lines, and they come out in the same order as the code:

console.log("Wake up");
console.log("Brush teeth");
console.log("Eat breakfast");
// prints:
// Wake up
// Brush teeth
// Eat breakfast

Swap the first two lines and the output swaps too. This sounds obvious, but a large share of beginner bugs come from statements in the wrong order: using a value before it has been calculated, or printing a total before adding the last item.

Comments are notes for people

In the example above, the lines starting with // are comments. JavaScript skips everything from // to the end of that line, so you can write notes to yourself or to other readers. For a note that spans several lines, start it with /* and end it with */. Comments are also a handy way to switch a line off without deleting it: put // in front of it and it no longer runs.

When something goes wrong

JavaScript is case sensitive: console.log works, but Console.log and console.Log do not. A misspelled name such as consol.log stops the program with a message like ReferenceError: consol is not defined. A missing closing quote or bracket gives a SyntaxError, which means the code is not valid JavaScript at all, so nothing runs. Error messages look alarming at first, but they are the computer telling you where it got stuck. Read the first line of the message, find the name it mentions, and compare it with your code character by character.

How the practice boxes work

Each practice box has your code on the left and the output on the right (below it on a phone). Play runs the code, and Ctrl+Enter or Cmd+Enter does the same from the keyboard. Check runs the code and compares each printed line with the expected answer, so spelling, capital letters and spaces inside the line all count. Start over brings back the original code. The code runs in a sealed frame, so you cannot break anything by experimenting.

BackgroundJavaScript was invented by Brendan Eich at Netscape and first appeared in the Netscape Navigator 2 browser. Work on a shared standard began in November 1996, and Ecma International adopted the first edition of the standard, called ECMAScript and numbered ECMA-262, in June 1997. The language is still updated once a year. The 17th edition, ECMAScript 2026, was published in June 2026. Browser makers build their JavaScript engines to follow that document.
programA list of instructions a computer carries out in order
programming languageA language with strict rules for writing programs, such as JavaScript
statementOne complete instruction, often ending with a semicolon
console.logPrints a line of output to the console
commentText after // (or between /* and */) that JavaScript ignores
syntaxThe grammar rules of a programming language
SyntaxErrorThe code breaks the grammar rules, so nothing runs
case sensitivelog and Log are different names
  1. What does this print?
    console.log("Hi");
    console.log("there");
    • Hi there on one line
    • Hi, then there on the next line
    • there, then Hi
  2. What does this print?
    console.log("Snack");
    // console.log("Nap");
    console.log("Walk");
    • Snack and Walk
    • Snack, Nap and Walk
    • Only Snack
  3. Which line prints the word Hello?
    • Console.log("Hello");
    • console.log("Hello");
    • console.log(Hello");
  4. Do the double quotes appear in the output of console.log("Yes")?
    • Yes
    • No, only Yes is printed
  5. Which symbol starts a comment that runs to the end of the line?
    • //
    • ##
    • <!--
  6. You run consol.log("Hi"). What happens?
    • It prints Hi
    • It stops with a ReferenceError: consol is not defined
    • It prints consol
  7. How many lines does this print?
    console.log("A");
    console.log("B");
    /* console.log("C");
    console.log("D"); */
    console.log("E");
  8. What is one complete instruction in JavaScript called?
    • A statement
    • A comment
    • A console
  9. A line is missing its closing quote: console.log("Hi);. What kind of error is this?
    • SyntaxError
    • ReferenceError
    • No error, it prints Hi
  10. Which organisation publishes the ECMAScript standard that JavaScript follows?
    • Ecma International
    • W3C
    • ISO only
Key points
  • A program is a list of instructions run from top to bottom.
  • console.log("text") prints one line.
  • Text goes inside quotes; the quotes are not printed.
  • // starts a comment; JavaScript skips it.
  • JavaScript is case sensitive.