This week's learning topics included:
1. Last week's homework on method overriding and the new keyword in C#.
2. LINQ exercises on Union, Concat, OrderBy, OrderByDescending, and where clauses.
3. Select and SelectMany LINQ projection operators to select values from collections and nested collections.
4. Javascript functions including direct declaration, anonymous functions, self-invoking anonymous functions, and closures which combine a function with its enclosing environment.
2. 本週主題
• 上週作業-override & new
• LINQ
– 作業四
– 作業五
– Select & SelectMany
• Javascript
– function
– Self invoking anonymous function
– Closures
3. 上週作業-Override and new
•
{A} nemo = new {B};
{A} {B} move moveby
override
Animal Animal move by:run run
Fish Fish move by:swim swim
Animal Fish move by:swim swim
Fish Animal Error
new
Animal Animal move by:run run
Fish Fish move by:run swim
Animal Fish move by:run run
Fish Animal Error
當方法重複時C#會先使用父類別的方法
6. Select、SelectMany
• Select and SelectMany are projection operators. Select operator is
used to select value from a collection and SelectMany operator is
used to select values from a collection of collection i.e. nested
collection.
7. Javascript
• First-class function
– The language supports passing functions as arguments to other functions,
returning them as the values from other functions, and assigning them to
variables or storing them in data structures.
• Prototype-based programming
– Prototype-based programming is an OOP model that doesn't use classes, but
rather it first accomplishes the behavior of any class and then reuses it
(equivalent to inheritance in class-based languages) by decorating (or
expanding upon) existing prototype objects. (Also called classless, prototype-
oriented, or instance-based programming.)
10. Javascript - Closures
• A closure is a special kind of object that combines two things: a
function, and the environment in which that function was created.
The environment consists of any local variables that were in-scope
at the time that the closure was created.
• Closures are functions that refer to independent (free) variables. In
other words, the function defined in the closure 'remembers' the
environment in which it was created.