by Cosmin Potocean
web developer
questions
questions
Q&A is focussed on programming, not on DOM manipulation
Answers to be further discussed
Internal vs. External memory sorting
distributed problem, multiple files
CPU intensive
Sorting Algorithms Speed? Complexity
Would you start writing from scratch?
libraries available
programming approach:
page scrapping with Node.js, using modules: request and cheerio
Application Architecture
Classes & Objects
Class: a template used to create multiple Objects
Inheritance
Polymorphism
Automobile:
Car
Motorcycle
Car Parks:
Level
Location
Space
You are expected to understand all the OOP concepts.
Recommended read:
Professor Frisby's Mostly Adequate Guide to Functional Programming
First Class Functions?
can treat functions like any other data type ... they may be stored in variables, arrays, passed around, composed...
a function can contain:
-code
-name (optional)
-primitive types
-objects
-other functions
-arguments
Functional? computation as the evaluation of mathematical functions - avoids changing-state and mutable data.
Another recommended read: JavaScript Allonge
https://leanpub.com/javascriptallongesix/read
== checks value
type conversion (coerces type)
=== strict equal
checks value and type
reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness
Why use ==?
coerces type
best to avoid!
Primitives by value
(the value of var1 gets copied to var2)
//changing var2 does not impact var 1
Objects by reference (copy of reference)
//change(mutate) of obj2 impacts obj1
Functions are hoisted to top
Variables declarations are hoisted to top (not the assignment)
step 1: JavaScript parser reads code and set’s memory spaces
//similar to reading an algorithm and setting aside the requirements for space (memory)
step 2: then executes the program....meaning variables and functions were already declared in step 1
The inner function execution context closes in the outer (lexical scope) variables and can access them
why important?
prototypal inheritance
inheritance: objects gets access to another object methods
prototype is a reference to proto object
each object has a proto object
MAKE OBJECTS:
1)Function Constructors
- a function that is used to construct objects
adding new changes behavior & don’t forget to add it: new!
2)Object.Create // prototypal inheritance creates objects from other objects
3)ES6 classes, class is still an object not a template!!
3 ways to mimic OOP classes!! ... ... stay functional!
& most important CODE CODE CODE
Good place to start