Data Types
Number
: numbers with decimals
BigInt
: any number, greater than 253-1 or less than -(253-1)
String
: letters, numbers, spaces, symbols, etc
Boolean
: true or false
Null
: the intentional absence of a value
Undefined (given value doe not exist)
: the absence of a value, but different from null.
Symbol
: unique identifiers
Object
: collections of related data
Arithmetic Operators
+: Add
-: Subtract
*: Multiply
/: Divide
%: Remainder
methods
a period (the dot operator)
the name of the method
topening and closing parentheses
ex)
.toUpperCase()
.trim() // remove white space
Built=in objects
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
Variables
: a container for a value (username, account number...)
string interpolation?
: Using template literals to embed variables into strings.
Object Oriented Programming (OOP, 객체지향 프로그래밍)?
: A programming paradigm that uses the concept of "object" to structure code. The fundamental idea behind OOP is to organize code into reusable and modular components, called objects, which present real-world entities or concepts.
OOP가 좋은 점
1. Code Reusability
: OOP promotes the creation of modular code by organizing it into classes and objects. Each class represents a self-contained module with its own data and behaviour.
: Code reuse is facilitated through inheritance, allowing the creation of new classes by inheriting attributes and methods from existing ones. This can lead to more efficient and maintainable code.
2. Encapsulation
: It helps in hiding the internal details of an object and exposing only what is necessary. This protects the integrity of the object and prevents unintended external interference.
: It makes it easier to manage and modify the internal implementation of a class without affecting the code that uses the class.
3. Abstraction
: It allows developers to focus on high-level concepts and ignore low-level details during the design and implementation of a system.
: It provides a clear separation between what an object does and how it achieves its functionality.
4. Inheritance
: It allows the creation of new classes based on existing ones, inheriting their attributes and methods. This promotes code reuse and the establishment of a hierarchical relationship between classes.
5. Polymorphism
: It enables objects of different classes to be treated as instances of a common base clase. This enhances flexibility an extensibility in code, making it easier to adapt and expand systems.
6. Easier Maintenance and Modification
: OOP makes it easier to maintain and modify code because of its modular and organized structure. Changes can be localized to specific classes without affecting the entire system.
: This is particularly beneficial in large-scale projects where collaboration among developers in common.
7. Improved Software Design
: OOP encourages a more natural representation of real-world entities and their interaction. This can lead to a more intuitive and comprehensible design, making it easier for developers to understand and work with the code.
이전에는 Procedural Programming was the dominant programming paradigm.
In procedural programming, the emphasis is on procedures and routines, and the flow of control is determined by the sequence of statements in the code.
Encapsulation
Inheritance
Poylmorphism
Abstraction
Falsy values
0
Empty strings like "" or ' '
null (when there is no value)
undefined
NaN or Not a Number
Scope
Scope Pollution
: having too many global variables can cause problems in a program.
Iterators
.forEach()
.map()
.filter()
.findIndex()
.reduce()
.every()