SemanticsWorks in <code />
About me
  • Sep 30, 2020

    Angular component field initialization

    In my previous post, I talked about Class field initialization in typescript. How about field initialization of angular component, is it different? Angular component is defined an typescript class. It should follow same logics. However, Angular component has life cycle. The ngOnInit is special method that angular will run angular first displays the data-bound properties and sets the directive or component's input properties. So if your initialization code depends on these data-bound proprties and input properties, you can not run them in constructor. So the following code doesn't work

  • Sep 30, 2020

    Please your library user with typescript generic

    In typescript, generic is a tool that api/library author to please its consumer. What does this means.

  • Sep 30, 2020

    Class field initialization in typescript

    In typescript class, you can define your field initialization in multiple ways. Here is one typical way to do that.

  • Apr 12, 2016

    A JavaScript interview question which can be fixed by 'let'

    A very popular JavaScript interview question on Lexical scope and closure is like the follow.

  • Aug 26, 2015

    Minimize the price (not the benefit) of type in Typescript

    I watched Anders Hejlsberg introducing typescript in 2012. Then I thought I don't have the problem it tries to solve. Type in Javascript has not yet caused any problem for me, as I have unit test, renaming and intellisense is also not a problem for me, because I have webstorm. Then, I found that Douglas Crockford said something in google plus

  • 2
  • 3
  • 4

Subscribe

  • Fred Yang

A blog of a frontend developer