findLastIndex(predicate: (T) =>boolean, index: number = this.length): number { for(vari = index; i > -1; i--) { if(predicate(this.list[i])) { returni; } } return-1; }
٥٥Instance
22
C# @
> > > @ >
>
< > > >@ @ @ >@ < @ @ . < .
> List @
> >
this.length
. > < > @
:
56
(index: number = this.length) (index: number = this.someMethod()) (index: number = this.someDependency.someMethod()) (index: number = StaticClass.someMethod())
> .>> @ @ @ < > .> . > > > > > > > < @ @ >
List.prototype.findLastIndex = function (predicate, index) { if (typeof index === "undefined") { index = this.length; } for(var i = index; i > -1; i--) { if (predicate(this.list[i])) {
٥٦Static
23
C# @
return i; } } return -1;};
@
> @ > » ) >. @ > > . @ > . >
9.2
@
C#
> @ @ >. @ @ >
> >> > > @ > (>
>
C# >
->
@
57
«@
number string
.
>
any
>>
moduleOverloads { export class Example { overloadedMethod(input: string); overloadedMethod(input: number); overloadedMethod(input: any) { return input.toString(); } } } Var example = new Overloads.Example(); example.overloadedMethod(1); example.overloadedMethod('A String');
٥٧
implementation signature
24
C# @
25
C# @
58
@ >>
> @ >>
10
>
>.
C# >
>> . @ >
enum >
Enum States { Solid, Liquid, Gas } Enum Sizes { Small = 3, Medium = 5, Large = 8 }
.
. Class MyType { constructor(public name: string) { } } Var simpleTypedArray: string[] = []; Var complexTypedArray: MyType[] = []; //simpleTypedArray.push(2); // not allowed simpleTypedArray.push('Some String'); var arrayItem = simpleTypedArray[0]; // string
>@ > >> @ @ @ > > .> > > @ >
>
C# >
>
Class List { private list: T[] = []; constructor(list?: T[]) { this.list = list || []; } getlength(): number {
٧٢arrays
44
C# @
returnthis.list.length; } add(obj: T): void { this.list.push(obj); } addRange(...items: T[]): void; addRange(items: T[]): void; addRange(items: T[]): void { this.list = this.list.concat(items); } clear() { this.list = []; } contains(obj: T): boolean{ for(var i = 0; i TOutput): List { Var list = new List(); For (var i = 0; i boolean): T { for(var i = 0; i boolean): T { var results = new List(); for(var i = 0; i boolean, index: number = 0): number{ for(var i = index || 0; i boolean, index: number = this.length): number { for(var i = index; i > -1; i--) { if(predicate(this.list[i])) { returni; } } return-1; } forEach(action: (obj: T) =>any): void { for(vari = 0; i . > @ @ @ > >. > >
List
@
.Net >
Var list = new List(['One', 'Two']); alert(list.length.toString()); // 2 alert(list.getItem(1)); // 'Two' list.addRange(['Three', 'Four']); alert(list.length.toString()); // 4 // Example using rest parameters overload
48
C# @
list.addRange('Five', 'Six'); // Example using the array overload list.addRange(['Seven', 'Eight']); var stringList = new List(['12', '12', '3']); stringList.forEach(function (str: string): void { alert(str); } );
49
C# @
17
@> > Date @ > > 00:00:00 1970 1
.>
Date
.
// Year, Month, Day Var myDate = new Date(2012, 05, 12); // Year, Month, Day, Hours, Minutes, Seconds, Milliseconds Var myDateTime = new Date(2012, 05, 12, 15, 33, 10, 100);
@> 1970 1
@
ISO RFC
> > >
> > > @ > 00:00:00
.
Var dateFromRfc = new Date('12 Dec 2011 00:50:00 +0000'); Var dateFromIso = new Date('2011-01-31T18:30:00'); vardateFromNumber = new Date(1369251402587);
classTypes { staticgetType(inputClass) { var funcNameRegex = /function (.{1,})\(/; var results = (funcNameRegex).exec(( inputClass).constructor.toString()); return(results &&results.length> 1) ? results[1] : ''; } } Class Example { } Class AnotherClass extends Example { } Var x = new Example(); Var y = new AnotherClass(); alert(Types.getType(x)); // Example alert(Types.getType(y)); // AnotherClass