Upload
learningtech
View
367
Download
1
Embed Size (px)
Citation preview
本週主題• 上週作業 -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 runFish Fish move by:
swim swim
Animal Fish move by:swim swim
Fish Animal Error
newAnimal Animal move by: run run
Fish Fish move by: run swimAnimal Fish move by: run run
Fish Animal Error
當方法重複時 C#會先使用父類別的方法
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-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.
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