Problem Domains represent the scope of work you are trying to solve with the code you are writing for a given problem.
- they are difficult to solve when you don't have a complete/clear picture of what you are building
- understanding the problem domain is critical aspect of software development
- make the problem domain easier to understand by breaking it down into easy to understand segments
- work with the customers, users and product managers to ensure you fully understand the problem domain before you start coding, and don't be afraid to ask clairifying questions as needed.
All data types can either be bucketed into
- Primitive Values - when assigned to a variable, the variable is set to that value directly
- immutable (cannot be changed)
- Object References - when assigned to a variable, it contains a reference to the variable
- mutable (can be changed)
- if you assign an object to another object and change the value of a property it will change both objects
- Object.assign should be used if trying to copy an object
- when using comparision operators objects are checking to see if the reference address is the same so if two different objects contain the same property and value they will still return false
object1 { name: John} === object2{ name: John}; return will be false (objects have different reference addresses in memory)
JavaScripts Eight (8) Data Types:
- String - primative value
- Number - primative value
- Boolean - primative value
- Undefined - primative value
- Null - primative value
- BigInt - primative value
- Symbol - primative value
- Objects - object reference
Objects group together sets of variables and functions to form a model of something
- variables in objects are referenced to as properties
- functions in objects are referenced to as methods
Defining an object:
const object_name = {
property1: value,
property2: value,
method1: function{
code to be executed
}
}
The browser represents a webpage using the Document Object Model or DOM
Four Node types:
- Document Nodes
- starting point for all other nodes ()
- Element Nodes
- can be selected by id (
#), class (.), or tag name - update content using .textContent (DOM Manipulation) and .innerHTML, avoid innerText
- .innerHTML has security risks but is quicker than DOM manipulation be aware of Cross-site scripting attacks (XXS)
- can contain multiple text nodes
- can contain multiple sibling child elements
- can be selected by id (
- Attribute Nodes
- part of the element, not childeren of the element
- Text Nodes
- no further nodes can come off of a text node
When DOM query can return more than one node it will return a node list
- accessing an element directly will result in a more responsive website because you are filtering through fewer nodes
- getElementById() and querySelector() can both access elements directly