JavaScript Basics
JavaScript
The primary programming language of the web, primarily used for adding functionality
to websites. JavaScript is a general purpose multi-paradigm programming language with
dynamic typing.
Learn more: https://developer.mozilla.org/en-US/docs/Web/JavaScript
Paradigm
A style of programming. Oftentimes languages are built with a specific
paradigm in mind, but JavaScript is known as a multi-paradigm
language, because it allows for programming in a variety of paradigms.
Some of the major paradigms of JavaScript include:
-
Event-driven: Functions can be made to respond to events, such as when a
user clicks on an element or scrolls down the page.
-
Functional: Functions can be written as "pure functions", meaning
functions that always have the same output for a given set of arguments
and never produce side effects. Additionally, JavaScript supports
first-class functions and higher-order functions. This
means that functions can be treated as normal values, passed as arguments
to other functions and returned from functions.
-
Object-oriented: Objects can be created as custom data stores and
they can be made to inherit from each other.
-
Imperative: Programs can be written by explicitly describing the
control flow, such as with loops and conditionals.
-
Declarative: Programs can be written by describing the desired output
with implicit control flow. Oftentimes this is associated with functional programming
(e.g. using the forEach function to loop over an array instead of a for loop).
Primitive
The most basic data types of a language. In JavaScript, there
are 7 primitive types:
-
Number: Numeric values, including integers and decimal values.
-
BigInt: Integers too large to store in a number.
-
Boolean: A binary value of true or false.
-
String: A sequence of characters.
-
Symbol: A dynamically generated unique value.
-
Null: A nonexistent value.
-
Undefined: A value that has not been set.
JavaScript has a typeof operator that
can get the type of a value as a lowercase string.
However, do be aware that this function does have some
special casing. For example, typeof function
will return "function" even though functions are
just objects.
Learn more: https://developer.mozilla.org/en-US/docs/Glossary/Primitive