js basics

refer to : https://www.udemy.com/course/the-web-developer-bootcamp/

1. primitive types基本类型

  • the basic building blocks
    • Number
    • String
    • Boolean
    • Null
  • technically, there are two other primitive types, Symbol and BigInt

Undefiend.  eg: youtube web page, 点赞数:number; 标题: string;是否订阅: boolean; 在console里面写js注释的时候,返回类型是undefined


2. Numbes IN JS

Js has one number type: positive numbers, negative numbers, whole numbers(integers), decimal numbers


3. basic operations:addtion, substraction, multiplication, division.

%  modulo.    remainder operator: check number is odd or even

** exponentiation    2**4 = 16.    two to the fourth power


 4. what is NAN?

It is NOT A NUMBER.  eg: 0/0.   1 + NAN


5. Variables & let

basic syntax: let someName = value;   keywork: let


6. clear().  to clear console


7. const. const works just like let, except you can not change the value.

why use const: to define some unchanged variables, const variables can not be reassigned.

eg: const pi = 3.14159.  const daysInWeek = 7.  


 8.  camel-cased, with the first letter lowercased.


9. In JS, the variables can be changed into another type, but in typescript, there are restrictions, you can not change the variables' type.


原文地址:https://www.cnblogs.com/LilyLiya/p/14244337.html