Basic Concepts Flashcards
JavaScript is defined as…
A lightweight, multi-paradigm, single-threaded, dynamic scripting language that is found in all modern web technologies
The main 8 types of the JavaScript language
1) Number
2) BigInt
3) String
4) Boolean
5) Object
6) Null
7) Undefined
8) Symbol
How is the Number type implemented
As a double-precision 64-bit binary format IEEE 754 value
What are some subclasses of Objects available to you in JavaScript
- Function
- Array
- Date
- RegExp
- Math
parseInt()
this will parse a string into an integer value, where the first parameter is the string, and the second is the base you want to parse out.
NaN
This means ‘Not a Number’, and is the result of trying to use a non-number value in a number context.
i.e. parseInt(‘hello’, 10);
use Number.isNaN(value) to check for NaNness
NaN is ‘toxic’
Any mathematical operation with a NaN, will result in NaN
parseFloat()
Similar to parseInt, but only uses base 10 and will output the floating point representation of the value parsed.
Falsy Values
False, 0, “”, NaN, null, undefined
Truthy Values
Anything that is not Falsy
let vs. const. vs. var
let: declares a mutable variable in block scope
const: declares an immutable variable in block scope
var: declares a mutable variable with global scope (DONT USE)
for…in vs. for…of
for in is used to iterate over enumerable values. It is good for checking the existence of keys in a map/object. does not guarantee order of enumeration.
for of is useful for iteration of iterable values, so arrays, strings, etc. more often than not, this will be the preferred one.
x && x.name
as long as x exists, return x.name
x.name || x.getName()
if x.name doesn’t exist, get it
A variable can start with
Any letter along with $ and _