Javascript Terms
Terms | Operators | Language | Objects | Rules |
A brief introduction to a simple and powerful programming language
Why is javascript more powerful than HTML?
- Javascript is a programming language - it has logic, arithmetic operators, objects and constants and variables. HTML only executes in the order it is written and displays text or images - it has no logic or operations.
- Javascript can operate on the DOM - enabling it to interact dynamically with any page element to change or create the display and react to the information the user supplied. HTML creates the elements and javascript acts on them (and css styles them)
Terms and Basics
- Scripting Language
- A language that is interpreted and executed simultaneously. Examples: javascript, perl. Advantages: simple to learn and quick to use/change.
- Compiled Language
- A language that is pre-processed to turn it into an efficient language that the computer understands. Examples: FORTRAN, C++, .NET, Java. Advantages: usually more capable and powerful, runs more efficiently.
- Data Type
- One of several kinds of data that a language recognizes. Javascript understands objects, strings (text), numbers (integers or reals), arrays, and boolean (true or false) values
- Scalar
- Having a single value. String, number and boolean are scalar types.
- Array
- A type of variable that has multiple values at the same time. It is a way to name a set of values with a single name.
var stopLightColors = Array("red","yellow","green");
var beatles = Array(4); - Numeric Array
- An array in which an item in the array is designated with an index number such as collections[3]. The first item in a numeric array is designated [0]
var collections = Array(4); - Associate Array
- An array in which the items are designated with a string name such as
collections["stamps"].
var collections = Array("shells", "toys", "coins", "stamps"); - Strongly or Loosely Typed
- "Type" has to do with how strictly a language enforces variable typing. Strict languages don't allow you to define something as an integer and later use it as text or a real number. Javascript is a very loosely typed language - it has one type of variable and you can put any kind of value into it.
- Function
- A named piece of code that can be used over and over and returns a value or performs a task. The syntax to call a function is function_name(argument-list)
- Argument
- The values or parameters that are given to a function to operate on. An argument list is simply more than one argument separated by a comma. Example: (argument1, argument2, argument3)
- Scope - global or local
- The extent of the definition of a variable. In javascript all variables are global, meaning they have meaning everywhere, except variables defined inside a Function, which have meaning ONLY inside that function.
- Declare
- When you declare a variable you make a space for it and give it a name. You may give it a value at the same time but this is not required. Declaration is a good discipline but not required in Javascript.
var mood; //Declare the variable called mood
var bugs = "ant"; //Declare the variable bugs and assign the value "ant"
age = 31; // no declaration, just assigning a value (acceptable but better to declare the first time you use it) - Assignment and Population
- Giving a value to a variable is Assignment. Giving values to an array is Population.
age = 32; //Assign a value of 32 to the variable age
beatles[3] = "Ringo"; //Populate the 4th item in the Array beatles with "Ringo" - Operator
- A symbol that indicates the operation or function that is to be performed by the code. Operators are pre-defined for the language. Javascript has Arithmetic, Assignment, Logical, Comparative, and Conditional operators. See Operators
Page Updated
12.08.2009
