Advanced JavaScript and AJAX

The basics of how the JavaScript programming language works
  • In the JavaScript programming language, all functions and variables are actually properties and methods of the special object, which is called the LexicalEnvironment.
  • The largest LexicalEnvironment, in the search engine, is window, which is also called global object.
  • Top-level variable instantiation is the next step where the interpreter scans all var declarations and creates the properties of the window object.
  • During the phase of scanning var declarations  and creating window properties,  no variable value assignment is performed. This process will be realized only in the next phase.
  • When the function is called, the LexicalEnvironment of that function is immediately created, which is populated with the function arguments and declarations defined inside the function body and local variables.
  • Unlike the window object, LexicalEnvironment functions are not open for direct access, but can only be accessed from the body of the function.
  • The variable created within the function using the  var command becomes local.
  • In JavaScript,  scope  is a set of variables, objects, and functions that can be accessed.
Object-oriented JavaScript
  • The delete command must be used to delete object properties.
  • JavaScript belongs to the group of prototype-based object-oriented languages.
  • The inheritance of the object, i.e. the creation of a new object based on the example of an already existing object, can be executed through the create() method. 
  • Existing prototypes can be further specialized by new prototypes that inherit and modify their behavior.
  • Creating the instance of the class is called instantiation.
  • Although there is no syntactic rule, by convention properties that are considered private and should not be modified are named with an _ (underline) sign at the beginning.
  • If the function has a constructor role, by convention, its name starts with an uppercase letter, and all other functions have a lowercase letter at the beginning.
Working with XML
  • XML is a tool for storing and transporting data that is independent of software and hardware.
  • Each XML file should have a declaration.
  • XML syntax, like HTML, is based on tags and the tree structure of documents, with the difference that XML syntax is somewhat stricter than HTML.
  • DTDs (Document Type Definitions) provide the basic ways to define the rules that the XML document must follow.
  • Although XML data has an easy-to-read structure and is therefore simpler to decode by hand, most programming languages ​​have classes or functions for manipulating this format.
  • XPath is one of the complementary technologies for working with XML.
  • JSON is the serialization that is very popular in JavaScript.
  • Due to the similarity of the syntax to the JavaScript object, with the help of built-in functions, it is very simple to perform the conversion of the JSON record to a regular JavaScript object.
  • Using eval() instead of JSON.parse() carries some security risk, and therefore using eval() should be avoided.
Working with the XMLHttpRequest object
  • The XMLHttpRequest object   allows sending synchronous and asynchronous http requests from JavaScript and downloading the response.
  • The readyState attribute   of the  XMLHttpRequest object contains information about the current state of the request.
  • Sending the request through the XMLHttpRequest object is achieved through the  open()  and  send() methods.
  • The onreadystatechange event   fires when the status of the XMLHttpRequest object changes.
  • The status attribute   contains the status code of the http response.
AJAX – Asynchronous JavaScript and XML
  • AJAX is the WEB development technology for creating interactive web applications.
  • AJAX is short for: Asynchronous JavaScript and XML.
  • When we want to do an asynchronous operation with binary content, the procedure is different from the standard one.
  • On file upload, enctype must be multipart/form-data.
  • With iframe we define inline frame, with the help of which we can embed another document within the already existing HTML page, in which the iFrame is defined.
  • One of the important advantages that AJAX provides to the user is that the user can continue using the application while AJAX is communicating with the server.
  • AJAX is the most widely used Rich Internet Application (RIA) technology.
  • AJAX is based on open standards (Open Standards).
Advanced work with regular expressions
  • Regular expressions in JavaScript can be activated in two ways. The first using the RegExp class and the second using the string.
  • If we want to create a class for regular expressions, we use the constructor var rg = new RegExp(“reg”);.
  • If we create a regular expression using the string, we use the slash tags: var rg = /expression/.
  • To check the expression we use the string and the RegExp functions (methods): exec, test, match, search, replace and split.
  • The sequence in regular expressions is marked with square brackets: [], [0-9], [az].
  • Quantification is performed with braces: {2,3}.
  • Special characters in regular expressions are represented by the sign: \.
Real-time work – animation
  • Server languages ​​don’t have real-time execution, but clients do.
  • JavaScript is not a multithreading language, that is, we have the possibility of executing only one process during the program.
  • Unlike setInterval, this function gives us better control over the execution time.
  • In JavaScript, rendering complex, dynamic content in real-time is a challenge.

Recommended reading

1. Zakas N. C, Principles of Object-Oriented JavaScript, No Starch Press, 2014.
2. Goodman D, Morrison M, Novitski P, Rayl T, JavaScript Bible (7th Edition), Wiley, 2010.
3. Porteneuve C, Prototype and script.aculo.us: You Never Knew JavaScript Could Do This!, Pragmatic Programmers, 2007.
4. Franklin J, Beginning jQuery, APRESS, 2013.d
5. Flanagan D, jQuery pocket reference, O’Reilly, 2011.
6. Means G, Node for frontend developers, O’Reilly, 2012.Link-uri utile
1. http://docs.angularjs.org/guide/scope
2. http://docs.angularjs.org/api
3. http://docs.angularjs.org/guide/concepts
4. http://docs.angularjs.org/guide/forms
5. http://nodejs.org/
6. http://jade-lang.com/api/
7. http://api.jquery.com
8. https://www.ng-book.com
9. https://freefrontend.com/angular-books
10. http://api.jquery.com
11. https://madewithvuejs.com/blog/vue-js-books-you-have-to-read
12. https://books.goalkicker.com/NodeJSBook