
97717549b5098610703f0fdf701ba698.ppt
- Количество слайдов: 41
Java. Script Basics Stephen Delaney sdelaney@skokielibrary. info
Review: Creating Reusable Code with Functions • Creating functions • Returning values from functions • Variable scope
Creating a Function • When you see parentheses following a name, you know you’re seeing a function • No semicolon after the closing brace
Calling a Function • The bottom line calls the function
Return Statements • Return statements: • Pass a value (only one) • Exit immediately
Arguments and Parameters • The argument is stored in a variable called a parameter • person is the parameter • "Frank" is the argument
Variable Scope • Function scope vs. global scope
Variable Scope • Function scope vs. global scope
is. Na. N()
Throwing Errors
Questions?
Review
Variables • Variables must begin with a letter, $ or _ • Variables are case-sensitive • var person and var Person are two variables • typeof
Strings • Properties • i. e. string. length • Methods • i. e. string. to. Upper. Case()
Concatenation
Types of Numbers • Integers • 10, -8, 2787382 • Floating point numbers • 3. 14, -10. 6454 • Scientific notation • 5. 7 e+4 => 57000
Shorthand Operators • += • -= • *= • /= x += y is shorthand for x=x+y
Parsing Numbers • parse. Int() • parse. Int(10. 6) 10 • parse. Float() • parse. Float(10. 6) 10. 6
Terms • Na. N • Not a Number • DRY • Don’t Repeat Yourself
The Math Object • Math. round() • Math. round(10. 6) 11 • Math. floor() • Math. floor(10. 6) 10 • Math. ceil() • Math. ceil(10. 6) 11
The Math Object • Math. random() • Floating number, from 0 (inclusive) to 1 (exclusive)
Comparison Operators Operator Meaning True expressions == Equality 10 == '10' === Strict equality (2 * 5) === 10 != Inequality 9 != 10 !== Strict inequality '10' !== 10 > Greater than 20 > 10 >= Greater than or equal '10' >= 10 < Less than 10 < 30 <= Less than or equal '10'<= 10
And Operator: && Condition 1 Condition 2 Result TRUE FALSE TRUE FALSE
Or Operator: || Condition 1 Condition 2 Result TRUE TRUE FALSE FALSE
Not Operator: ! Condition Result TRUE FALSE TRUE
If Statements
What’s next?
Next Steps • j. Query • j. Query is used by 71. 8% of all websites. That is a Java. Script library market share of 96. 4%.
Next Steps • AJAX • • Asynchronous Java. Script And XML Get data without a page refresh
Next Steps • MEAN stack • “In the MEAN stack, we use Mongo. DB as our database. We write most of our code in Javascript. We rely on Node and Express. js to host our application and serve APIs/Views. We use Angular. JS to render our views that are served by Express. ”
Next Steps • MEAN stack
Navigate to library: • Sort by difficulty • Select course • Select Java. Script https: //teamtreehouse. com/library/top ic: javascript/type: course/sort: difficulty
Recommended Syllabus • Java. Script Loops, Arrays and Objects • Java. Script and the DOM • j. Query Basics • There is also a shorter one called Introduction to j. Query. • AJAX Basics
Recommended Syllabus • Interactive Web Pages with Java. Script • Object-Oriented Java. Script • Node. js Basics • Build a Simple Dynamic Site with Node. js • Express Basics • Build a REST API With Express • Mongo Basics* • Angular Basics* • Building a MEAN Application *Indicates a course that is not under Java. Script
No. SQL vs. SQL
Comparing No. SQL and SQL • Are you Google? • Do you know what you are building? • What framework are you in?
Comparing No. SQL and SQL • What is No. SQL? • SQL vs. No. SQL • The No. SQL Debate: Automatic vs. Manual Transmission • When should I use a No. SQL database instead of a relational database? • No. SQL Use Case Scenarios or WHEN to use No. SQL
Comparing No. SQL and SQL http: //db-engines. com/en/ranking
ORM
ORM • • Object-relational Mapping Translates between you and SQL Makes life easier! MEAN stack is optimized for Mongo. DB (Mongoose ORM), but if you would like to use SQL: • Sequelize • Treehouse: Using SQL and Node. js with Sequelize • Bookshelf. js
Thanks!
97717549b5098610703f0fdf701ba698.ppt