The following is the typescripts understanding
What is typescripts?
—————————————
differents between let and var
let is within the scope
var is available within the scope of nearest function
—————————————
declare let without any value then we can initialize it later
it will be type any without initialization, but then will be the first type that we initialize it to
type assertion(1): "let a = ( ___ ).methods"
type assertion(1): "let a = (___ as type).methods"
both does not change of the ___ at runtime
define type
let _: type;
possible declaration: let a: number[] = [_, _, _] let b: any[] = [_, _, _]
similar to java, we can use the enum and define constant with const
arrow function(lambda function)(note that this only works for 1 line of code)
normal form:
let _ = function(_){____________}
arrow function:
let _ = (_)=> ____________
cohesion: a method that perform single purpose instead of multiple purpose
interface is defined the following way: interface ____ {a:__, b:____}
object is instanceof a class
create an constructor: constructor(a?: type, b?: type){} "?" make this refferences optional
access modifier: public, private, protected
we can also add modifier inside the constructor input fields which make this constructor automatically create such variable
getter and setter
we can use the property of the field inside of the class
set _ instead of set_ (which will leads to cleaner syntax, use __.field = _ instead of set_(_);)
property is a method of the class (instead of field)
we can also use _field instead of field in constructor fields to make the getter and setter using the same case in the class
module
each files are modules we need to set export (use "export" keyword) in order to make the class inside of the file usable somewhere else in the program
to use modules, use "import" keyword (import {__} from 'path(without .ts extension)')