Presentation is loading. Please wait.

Presentation is loading. Please wait.

JavaScript: The First Parts Part One Douglas Crockford Yahoo! Inc.

Similar presentations


Presentation on theme: "JavaScript: The First Parts Part One Douglas Crockford Yahoo! Inc."— Presentation transcript:

1 JavaScript: The First Parts Part One Douglas Crockford Yahoo! Inc.

2

3

4

5

6 Learn to Program Values Variables Expressions Branching Loops Functions Recursion Arrays Objects Trees

7 Why should you learn to program?

8 In programming we construct and maintain extremely complex systems with aspirations of perfection.

9 Ulterior Motives

10

11

12 Programming Languages

13 JavaScript The world's most misunderstood programming language.

14 Learn to Program Values Variables Expressions Branching Loops Functions Recursion Arrays Objects Trees

15 Values Numbers, strings, booleans null undefined

16 Variables Values stored under names. The values can be replaced.

17 Expressions Elements of computation

18 Branching Alter the sequential flow of the program

19 Loops Repetitive operations

20 Functions Encapsulated expressions

21 Recursion Functions defined in terms of themselves

22 Arrays Linear sequences of storage

23 Objects Associative collections of named values

24 Trees Complex structures composed of objects

25 Inside every programming language there is a calculator Literal numbers with infix operators * used for multiplication / is used for division Precedence ( ) can change precedence 2 + 3 * 4 === 14 (2 + 3) * 4 === 20

26 The Yellow Box http://jsmvhs.crockford.com/yellowbox.html

27 Try these 0.3 - 0.1 0.3 - 0.1 - 0.1 - 0.1 1 / 0 JavaScript numbers don't always work like real numbers.

28 The result of an expression can be stored in a variable a = 3 + 4

29 a = a + 1

30 The naming of variables is a serious matter It isn't just one of your holiday games. Well chosen names can make a program self descriptive. A variable name should begin with a letter. It can contain any number of letters and digits. It can contain the _ (underline) character.

31 Functions Functions can encapsulate an expression. Functions can be stored in variables. Functions may have parameters. Functions can be invoked. Functions can grow the language.

32 function ( parameter ) { return expression ; } double = function (number) { return number * 2;} double(212)

33 function ( parameter ) { return expression ; } celsius = function (f) { return (f - 32) * 5 / 9;} boiling_point = celsius(212)

34 function ( parameter ) { return expression ; } quad = function (x) { return double(x) + double(x);} average = function (a, b) { return (a + b) / 2; }

35 Functions A function can take many parameters, or no parameters. If it takes more than one parameter, the parameter names are separated with commas. A parameter name is like a variable inside the function. When a function is called, the argument values are assigned to the parameters.

36 Assignment One 1.Read Preface, Chapter One of The Good Parts 2.Write function fahrenheit(c) 3.Write a function of your own that takes two or more parameters. 4.Using trial and error, determine the temperature such that fahrenheit(x) === celsius(x) Put your answers in a text or html file and add it to http://groups.yahoo.com/group/jsmvhs/files/Assignment1/ Use your unique ID in the name of the file.


Download ppt "JavaScript: The First Parts Part One Douglas Crockford Yahoo! Inc."

Similar presentations


Ads by Google