TIL: Today I Learned

[TIL] 20201125 JavaScript Basics

김알리 2020. 11. 25. 20:54

Primitive Types

  • Number
  • String
  • Boolean
  • Null
  • Undefined
  • Symbol
  • BigInt

 

 

JavaScript Numbers

  • JavaScript has ONE number type
  • Math operations
    • add : +
    • subtraction : -
    • multiplication : *
    • division : /
    • modulo(remainder operator) : %
    • exponentiation : **

 

 

NaN

  • "Not a Number"
  • NaN is a numeric value that represents something that is not a number.
  • ex) 0/0, 1+NaN

 

 

Variables

  • Labels for values
  • Basic Syntax
    • let x = value;
    • ex) let year = 1956;

 

 

Updating Variables

  • +=, -=, *=, /= operations
//EXAMPLES
//These two operations are exactly the same.

score = score+5;
score += 5;
  • ++, -- operations
    • add/subtract 1

 

 

Const & Var

  • const
    • stands for constant
    • The value can't be changed.
  • var
    • The old variable keyword.
    • Before let&const, var was the only option. There isn't really a reason to use it now.

 

 

Booleans

  • value: true, false

 

 

Variable Naming and Conventions

  • Hard Rules for Naming
    • No space allowed within the name.
    • Can't start with number.
  • Best Practices
    • Camel Cased : If there are more than one word for the name, start the first one with lowercase and others with uppercase.
    • Use recognizable names.

 

 

 

 

 

 

 

* This post is a summary of Udemy Course "The Web Developer Bootcamp" by Colt Steele.