The Document Object Model (DOM) is an application programming interface (API) for valid HTML and well-formed XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated. With the Document Object Model, programmers can build documents, navigate their structure, and add, modify, or delete elements and content. The browser creates the DOM as it reads the HTML. When an HTML document is loaded into a web browser, it becomes a document object. The DOM is represented as a tree-like structure. We can access the DOM using getElementById, querySelector .DOM data types are document, element, node-list. Every single web page you visit on your browser can be considered a “thing”, an “object” so to speak. And indeed, the document itself is always represented as an Object in JavaScript. That is, whatever you may see on the browser screen is not only represented in HTML but also in JavaScript as well. The “way in which JavaScript knows how to represent the document content”, or the “way a document content is accessed and modified” is called the Document Object Model, or DOM for short.You can think of the DOM as prescribing the hierarchical structure of HTML elements. So it’s not surprising that the JavaScript objects that access the DOM are built to reflect such a hierarchy.
Function – a block of code contained for reuse
Scope determines the accessibility (visibility) of variables. Local scope – accessible only within the function, global scope accessible outside the function
JavaScript is not an object-oriented language, it is a language that supports object oriented programming.
In JavaScript, everything is an object, even when it’s something else. Functions are objects. Strings are objects. Numbers are objects. Arrays are objects. Objects are objects.
As a result, anything can have properties assigned to it.
This is how a lot of methods work. For example, [1, 2, 3].length works because arrays are also objects and .length is a property of the Array object. Function.arguments is a property of the Function object.
You can assign properties to basically anything in JS.
Generally in JavaScript things are either classified as Primitives or Objects.
| Primitives | Objects |
| Numbers, Strings, Booleans | Array, function, Math, Date, Window, Document etc.. and objects you create |
But primitives can also behave like objects. Sometimes, that is. For example, you can get the length of String by using the length property on it like so:
JavaScript is often described as a prototype-based language — to provide inheritance, objects can have a prototype object, which acts as a template object that it inherits methods and properties from. An object’s prototype object may also have a prototype object, which it inherits methods and properties from, and so on. This is often referred to as a prototype chain, and explains why different objects have properties and methods defined on other objects available to them.
Well, to be exact, the properties and methods are defined on the prototype property on the Objects’ constructor functions, not the object instances themselves.
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
Callbacks are a way to make sure certain code doesn’t execute until other code has already finished execution.
Promises are a mechanism for handling asynchronous control flow in Java Script. Just like you give a promise – this would be done, if promise is successful it return certain value, if its failed – returns a error.
Its good because it avoid a call back hell. You can just write then then then…
Application Programming Interface (API)
In basic terms, APIs just allow applications to communicate with one another.
When people speak of “an API”, they sometimes generalize and actually mean “a publicly available web-based API that returns data, likely in JSON or XML”. The API is not the database or even the server, it is the code that governs the access point(s) for the server.
JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application
JavaScript Object Notation, and is a way to store information in an organized, easy-to-access manner. In a nutshell, it gives us a human-readable collection of data that we can access in a really logical manner.
HTTP = hypertext transfer protocol
HTTP is an application layer protocol that allows web-based application to communicate and exchange data. Its a messenger of the web. Is to computers need to communicate with each other to exchange data in a form of request response circle, they must speak the http protocol.
It is connectionless in the sense that it only connect at the moment of requests and responses.
It is also stateless: the client and the server know about each other just during the current request.
HTTP can deliver any sort of data as long as two computer can read it.
TCP/IP, or the Transmission Control Protocol/Internet Protocol, is a suite of communication protocols used to interconnect network devices on the internet.
TCP is a transport-layer protocol, and HTTP is an application-layer protocol that runs over TCP
Object Oriented Programming OOP – widespread paradigm regarding how to structure programs. It encapsulates functions and variable within objects. Helps to prevent conflicts between code in a large projects and organize functions/variables and make them reusable.
MVC is a architecture that defines how the program interacts with the user. Model is the components that interacts with database. Gets and sends data and runs database logic. The view is Rea component responsible for showing end user content. Controller is a middleware that gets requests from the view sends it to model . Get response from model and sends it to view. Controller is like waitress, model is cook with all the programs and data and end user is view. View is browser. Server is controller and data is model.
An API is an application programming interface. It is a set of rules that allow programs to talk to each other. The developer creates the API on the server and allows the client to talk to it.
REST determines how the API looks like. It stands for “Representational State Transfer”. It is a set of rules that developers follow when they create their API. One of these rules states that you should be able to get a piece of data (called a resource) when you link to a specific URL.
Each URL is called a request while the data sent back to you is called a response.