160 likes | 325 Views
JavaScript 101. Introduction to Programming. Topics. What is programming? The common elements found in most programming languages Introduction to JavaScript What software you will use to create and run JavaScript code. What is programming?.
E N D
JavaScript 101 Introduction to Programming
Topics • What is programming? • The common elements found in most programming languages • Introduction to JavaScript • What software you will use to create and run JavaScript code
What is programming? • A program is a set or sequence of instructions entered into a computer to perform work • Programs are written using programming languages
What is a programming language? • Programming languages consists of ways to represent information (data), and commands used to examine and/or change (update) information • Modern languages resemble human languages, combined with arithmetic and keyboard symbols
How does a computer execute a program? • Computers can only follow instructions written in their own language, machine code or binary code • Binary code consists of nothing but 0s and 1s • Programmer writes program, then that program needs to be translated into 0s and 1s
How does a program become binary code? • Two possible techniques: • Compiler: software that examines all the instructions, then translates full program into binary code • Interpreter: software that examines one instruction at a time, translating it to binary code
JavaScript • Next few weeks we will learn about programming with JavaScript • JavaScript uses an interpreter to translate program into binary code • Browser is the interpreter for JavaScript
Common Elements in Programming Languages • Most programming languages consist of the following: • Variables – data or information used in a program • Data types – categories of types of information a program is capable of recognizing and processing • Expressions – computer science term for a formula that generates a value
Common Elements cont. • Keywords – words that have a special meaning in a language, and cannot be used for any other purpose. Also know as reserved words. • Statements – commands that direct to computer to take some action • Functions – sections of code, or mini-programs, that execute a well defined task. Also known as sub-programs, methods, or sub-routines.
About JavaScript • Goal was to create a simple language that added interactivity to Web pages • Allows code downloaded with HTML to be executed on local machine
Client Server • Computer in front of you is example of a client • Machine hosting Web pages called a server • Before JavaScript, code always executed on the server • This was very slow! • Faster to download code and run it on the client
JavaScript can • Display different HTML depending on if the browser is IE or Netscape • Validate user input before transferring it to the server • Create dynamic effects and animation
JavaScript Features • Supported by IE and Netscape, although some differences exist • Source code embedded in HTML document • Programs respond to user actions, like mouse clicks • Compact and relatively easy to learn
JavaScript is Object Based • Other object based languages include Visual Basic and VB Script • Object based languages have built in objects ready to use • Objects are “packages” of data and commands combined in a single name • JavaScript objects include document, window, and others
What software? • Continue using Windows Notepad • Browser (IE 6.0)