Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript Informatics for economists I. Introduction Programming language used in web pages. Simple and easy to use – written in HTML document. Client.

Similar presentations


Presentation on theme: "JavaScript Informatics for economists I. Introduction Programming language used in web pages. Simple and easy to use – written in HTML document. Client."— Presentation transcript:

1 JavaScript Informatics for economists I

2 Introduction Programming language used in web pages. Simple and easy to use – written in HTML document. Client scripting language – script is sent with HTML document to web browser (client). JS is not Java. It has just similar syntax.

3 Characteristics Interpreted lang. – no compiling Object oriented – uses web browser and built-in objects Browser dependent Case sensitive Syntax is similar to C or Java language.

4 Limitations Works in web browser only. User can disable JS in browser. Many different JS versions. Cannot access to files or system object. Cannot save data.

5 Writing JS scripts Use tags. Example: document.write(“Hello world!”);

6 JS variables Initialized when firstly used. Case sensitive Example: var x, y; x=10; y=”Hallo”;

7 JS operators value assignment: = numeric operators: +, -, *, / logical operators: ==, !=,, =

8 Conditions Used to decide whether the expression is true or not if (expression) { commands when true; } else { commands when false; }

9 Cycles Used to repeat commands. while (expression) { commands; } for (initial value, condition, increment){ commands; }

10 Functions Frequently used part of program function name(params){ commands; return value; }

11 Object document Most frequently used object in JS. Contains everything on the page. document.forms document.images

12 Object Math Used with mathematical operations Math.abs(x)‏ Math.exp(x)‏ Math.pow(a,x)‏ Math.sqrt(x)‏ Math.PI

13 Events Activated when user does action onLoad – loading document onClick – cliking on object onDblClick – doubleclicking on object onMouseOver – move mouse over object onMouseOut – move mouse out of object onFocus – focusing object (activating)‏ onKeyPress – pressing key on object onSubmit – pressing submit form button

14 Communication with user Print information: alert(“some text”); document.write(“some text”); Get data from user: prompt(“prompt text”,”initial value”); parseInt, parseFloat Use forms:


Download ppt "JavaScript Informatics for economists I. Introduction Programming language used in web pages. Simple and easy to use – written in HTML document. Client."

Similar presentations


Ads by Google