Glossary - Canvas - JavaScript for Kids: A Playful Introduction to Programming (2015)

JavaScript for Kids: A Playful Introduction to Programming (2015)

Glossary

The world of computer programming has all kinds of special terms and definitions that can take some time to get the hang of. In this glossary, you’ll find definitions for many of the programming terms used in this book. As you’re reading this book, if you come across a term that you don’t quite understand, you can look here for a brief explanation.

argument

A value that can be passed into a function.

array

A list of JavaScript values. In an array, each value has an index, which is the numbered position of that value in the array. The first value is at index 0, the next value is at index 1, and so on.

attribute

A key-value pair in an HTML element. You can use HTML attributes to control certain aspects of an element, like where the element links to or the size of the element.

Boolean

A value that can be either true or false.

call

To execute or run a function. To call functions in JavaScript, you enter the function name followed by a pair of parentheses (with any arguments inside the parentheses).

camel case

A common way to name variables in which you capitalize the first letter of each word (except the first word) and then join all the words to make one long word, like so: myCamelCaseVariable.

comment

Text in a program that is not executed by the JavaScript interpreter—comments are just there to describe the program for the person reading the code.

conditional statement

A statement that executes code after checking a condition. If the condition is true, the statement will execute one bit of code; if the condition is false, it will execute a different bit of code or stop altogether. Examples include if statements and if...else statements.

constructor

A kind of function that’s used to create multiple objects so that they share built-in properties.

control structure

A way to control when a piece of code is run and how often it’s run. Examples include conditional statements (which control when code is run by checking a condition) and loops (which repeat a piece of code a certain number of times).

data

The information we store and manipulate in computer programs.

decrement

To decrease the value of a variable (usually by 1).

dialog

A small pop-up window. You can use JavaScript to open different kinds of dialogs in a browser, such as an alert (to display a message) or a prompt (to ask a question and receive input).

document object model (DOM)

The way that web browsers organize and keep track of HTML elements on a web page. These elements are organized in a treelike structure called the DOM tree. JavaScript and jQuery provide methods that work with the DOM to create and modify elements.

element

Part of an HTML page, such as a header, a paragraph, or the body. An element is marked by start and end tags (which determine what type of element it is) and includes everything in between. The DOM tree is made up of these elements.

event

An action that happens in the browser, such as a mouse click or a keyboard press by the user. We can detect and respond to these events with event handlers.

event handler

A function that is called whenever a certain event happens in a certain HTML element. For example, in Chapter 11 game, we create an event handler function that is called whenever the user clicks on a map image.

execute

To run a piece of code, such as a program or function.

function

A piece of code that bundles multiple statements so that they are all executed together. A function makes it easy to repeat a certain action in different parts of a program. A function can take arguments as input, and it will output a return value.

increment

To increase the value of a variable (usually by 1).

index

A number that indicates the position of a value inside an array. The index can be used to access a specific value in an array.

infinite loop

A loop that never stops repeating (often causing the interpreter to crash). This error can occur if the conditions of a loop are set up incorrectly.

interpreter

A piece of software that reads and runs code. Web browsers contain a JavaScript interpreter, which we use to run our JavaScript throughout this book.

jQuery

A JavaScript library that provides many useful methods for modifying and working with DOM elements on a web page.

key-value pair

A pair made up of a string (called a key) that is matched up with a particular value (which can be any type of value). Key-value pairs go inside JavaScript objects, and they are used to define an object’s properties and methods.

keyword

A word with a special meaning in JavaScript (for example, for, return, or function). Keywords can’t be used as variable names.

library

A collection of JavaScript code that we can load into our web pages to provide additional functions and methods. In this book we use the jQuery library, which gives us functions and methods for working with the DOM more easily.

loop

A way to execute a piece of code multiple times.

method

A function that is a property of an object.

null

A special value that can be used to indicate that a variable is purposely left empty.

object

A set of key-value pairs. Each key is a string that can be paired with any JavaScript value. You can then use the key to retrieve whatever value it’s paired with in the object.

object-oriented programming

A style of programming that takes advantage of objects and methods to organize the code and represent the most important features of the program.

programming language

A language that programmers can use to tell computers what to do. JavaScript is one programming language, but there are many others.

property

A name for a key-value pair in an object.

prototype

A property of a constructor. Any methods added to a constructor’s prototype will be available to all objects created by that constructor.

return

The act of leaving a function and returning to the code that called the function. A function returns when it reaches the end of its body or when it reaches a return keyword (which can be used to leave a function early). When a function returns, it outputs a return value (if no particular return value is specified, it simply returns the empty value undefined).

selector string

A string that represents one or more HTML elements. We can pass this string to jQuery’s $ function to select those elements.

string

A list of characters surrounded by quotes, used to represent text in computer programs.

syntax

How keywords, punctuation, and other characters are combined to make working JavaScript programs.

tag

A marker used to create HTML elements. All elements begin with a start tag, and most end with an end tag. These tags determine what type of element is created, and the start tag can include attributes for the element.

text editor

A computer program used to write and edit plaintext, without any special formatting like font style or color. A good text editor is helpful for writing programs, which are written in plaintext.

undefined

A value that JavaScript uses when something like a property or variable doesn’t have any particular value assigned to it.

variable

A way of giving a JavaScript value a name. After you assign a value to a variable, you can use the variable name later to retrieve the value.

whitespace

Invisible characters like spaces, newlines, and tabs.