29 Matching Annotations
  1. Aug 2022
    1. The unary plus operator (+) precedes its operand and converts it into a number. If it fails to convert the operand into a number, then it returns NaN. The unary (-) operator converts the operand into a number and negates it.

      an alternative to !!, in order to convert null, empty strings, boolean values into 0 or 1.

  2. May 2022
  3. Apr 2022
  4. Feb 2022
  5. Jan 2022
  6. Dec 2021
    1. The correct way to handle TypeScript functional destructuring is to define an interface and reference the interface after the destructure. TypeScript is then able to understand that the function takes an object argument that is of the shape of the Person interface and destructuring occurs as you would expect it to in ES6.
      // a 'Person' object requires 'first' and 'last' 
      // properties whose values are strings
      interface Person {
        first: string;
        last: string;
      }
      
      // This defines that the first functional argument 
      // must be an Array of 'Person' objects, then destructs
      // the first person's first and last name properties
      const helloFirstPerson = ([{ first, last }]: Person[]) =>
        `Hello ${first} ${last}!`;
      
      const people = [
        { first: 'John', last: 'Doe' },
        { first: 'Jane', last: 'Smith' }
      ];
      
      // outputs "Hello John Doe!"
      helloFirstPerson(people);
      
      /* --------- Example of a Type Error ----------- */
      // This creates an array argument that will be invalid for
      // the helloFirstPerson() function, because there are no 'last'
      // props on the 'people' objects
      const badArgs = [{ first: 'John' }, { first: 'Jane' } ];
      
      // Type Error! 
      // Property 'last' is missing in type '{ first: string; }'
      helloFirstPerson(badArgs);
      
  7. Nov 2021
    1. You'll use a (70%, 20%, 10%) split for the training, validation, and test sets. Note the data is not being randomly shuffled before splitting. This is for two reasons: It ensures that chopping the data into windows of consecutive samples is still possible. It ensures that the validation/test results are more realistic, being evaluated on the data collected after the model was trained.

      Train, Validation, Test: 0.7, 0.2, 0.1

  8. May 2020
    1. const Hello: React.FC<Props> = ({ who }) => (  <p>Hello, {who}</p>);

      最简单的 FC props定义方式

  9. Nov 2019
  10. Oct 2019
  11. Sep 2019
    1. ts-node enables you to execute TypeScript directly, just as you might execute JavaScript code using Node.
  12. Nov 2018
  13. Oct 2018
  14. Sep 2018