JavaScript Advanced Concepts


When it comes to boolean values, an expression that evaluates to true is considered truthy, while an expression that evaluates to false is considered falsy.
In JavaScript, undefined is a data type and null is a value. When a variable is declared but not assigned any value, it returns undefined. However, null can be assigned to a variable.
Both signs are comparison operators. The == compares values, and the === compares values and types.
When a function returns another function and that function is called from outside, it creates a closure for the outside function call. If another function calls the first function, then it creates another closure for that call. Each function call creates a new closure, which is stored as a reference. This is how closures work - by reference. Every new function creates new closures and stores a new reference.
When we define a method in local scope, it can only be accessed within that scope. However, if we want to use the method in another object, we can do so by calling the object and method like this: objectName.methodName.bind(newObject). Here, objectName is where the method exists, methodName is the method's name, and we pass newObject as an argument to bind the method. If we want to call the method directly from the object, we can use the call() method.
To use the call() method, we pass the object where we want to use the method and any arguments that the method needs. The call() and apply() methods are mostly similar, with just one difference. In the call() method, we pass the object we want to use and any arguments needed, separated by commas. In the apply() method, we wrap all the arguments in an array, except for the object name.
The Document Object Model, commonly referred to as DOM, is a representation of a web page created by a browser when it is reloaded. The HTML DOM can be thought of as a tree of objects. With the help of JavaScript, it is possible to modify elements, attributes, CSS styles, and events on the page.
API is an acronym for Application Programming Interface. It is a middleware that connects two applications or software to transfer data. On the other hand, GET is a method of retrieving data from a server or something similar to a server. Meanwhile, POST is the method of adding or saving data on a server.
JavaScript is a programming language that runs in the browser, and it works like this: when a user clicks somewhere on the screen, the browser identifies the area where the click occurred. The browser then searches for any event handlers (i.e. a function that runs when a specific event happens) that might be associated with that particular area. If an event handler exists, then the browser triggers the event and executes the code within the handler. After this, the browser checks if there are any other events that need to be triggered, and if there are, it repeats the process. This continues until there are no more events left to trigger. This entire process is known as the event bubble system, where events are propagated through the hierarchy of elements in the browser window.