本週學習心得分享
Vic Chih
2015-11-27
本週主題
• 上週作業-override & new
• LINQ
– 作業四
– 作業五
– Select & SelectMany
• Javascript
– function
– Self invoking anonymous function
– Closures
上週作業-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#會先使用父類別的方法
LINQ 作業四
• Union、Concat
• OrderBy、OrderByDescending
• where
LINQ 作業五
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.
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.)
Javascript-function
• 直接宣告:
– function declaration
• 匿名宣告:
– function expression
Javascript-Self invoking anonymous function
• Self invoking anonymous function
• 常用於一次性的呼叫
• Function內的變數或function都是區域性的無法在外使用
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.
Javascript - Closures
•
Reference
• http://www.dotnet-tricks.com/Tutorial/linq/N74N160714-Difference-between-Select-
and-SelectMany-in-LINQ.html
• https://en.wikipedia.org/wiki/Prototype-based_programming
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-
Oriented_JavaScript
• https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
Thank you for your listening

Vic weekly learning_20151127