I’ve Cracked the Code, Please Call Tech Support- Episode 14, Console-O

Alex Alban
4 min readNov 20, 2020

Last week of 211, and our deep dive on JavaScript. What started as a scary change of direction has actually been a great dive into a whole new skillset. As excited as I was to learn HTML and CSS, now I feel I can make even better sites and applications.

  1. Write about something you learned this week.

The primary focus of this week has been fetching and implementing API (application programming interfaces). This has really opened the door to what’s possible with building applications, as a whole new world of data manipulation is now possible. Everything from Star Wars facts to geolocation data is at your fingertips with this stuff. Pretty cool.

2. Why would you use something like the load event? Does this event have disadvantages? Do you know any alternatives, and why would you use those?

A load event in JavaScript executes a function when the whole page has been loaded. In addition to the JavaScript file this also includes all other dependent resources (think stylesheets, images, etc.).

The disadvantage here is just that — the entire page has to load in order for the user to interact with with anything that we’ve built. Depending on their machine and internet connection, that can lead to a less than stellar user experience. We don’t want that. We’re aiming for stellar.

An alternative here would be to use inline scripts. This allows the page to work while the JavaScript is still loading, but it’s much harder to maintain. Most developers that I have researched simply link their JavaScript at the bottom of the HTML, right before the closing </body> tag. This appears to strike the balance between functionality and customer UI experience. No one likes to wait.

3. What are the advantages and disadvantages of using Ajax?

Ajax is interesting! It’s a set of web dev techniques that can be used to assist in creating asynchronous web applications. Basically, Ajax allows web apps to send and receive data from a server asynchronously, without messing up the page you’re trying to use. No glitches or hitches.

The advantages here is that it allows the page to load, even if it doesn’t have every last bit of info from the server. This leads to faster rendering, better responsiveness, and happier users.

The disadvantages are that if a server doesn’t support JavaScript (rare) or has this functionality disabled, those users won’t be able to use Ajax dependent pages. Also, since the server is being pinged multiple times, that can lead to more data being consumed on the user’s end. Finally, if one data request fails, it can bring down the load for rest of the page. Not the whole page! But something is clearly up.

4. Explain how JSON works (and how it’s not really Ajax).

JSON (or JavaScript Object Notation) is a data format that’s pretty similar to a JavaScript object. The difference is that it can’t contain any functions or dynamic code. Strings, numbers, arrays and objects without functions only. This data can be parsed by a browser and inserted into the DOM (Document Object Model) of a web page, and is more or less readable by a human.

The key difference between Ajax and JSON is that Ajax is used to update a web page dynamically, and doesn’t have a particular structure in place to complete that task. JSON has a very well defined structure, and isn’t only used to update the web application (sometimes it isn’t used for the web app at all).

5. Explain Ajax in as much detail as possible.

Well, we’ve hit on most of the overall idea already. As stated above, Ajax (Asynchronous JavaScript and XML) is a set of techniques that can be used in order to assist a web page to load content asynchronously. The page can still be used, and Ajax will continue to load and update content the whole time, making things more usable and dynamic.

Ajax is not actually a programming language, instead being techniques that work with the JavaScript and XML specifically. It can request data from a web server and, when specified in the JavaScript and XML, can be used in order to update and change the content of a web page or application.

6. What does it mean when we talk about time complexity of an algorithm?

Well, contrary to what it sounds like, time complexity is not actually how long it takes for an algorithm to complete. Instead, it relates to the number of times a statement has to execute in order to resolve. So, if a function only runs once, but takes a long time to do so, that’s not actually time complex (just time consuming). If a function takes 0.3 seconds to complete, but executes 20 times, that’s a more time complex situation.

7. What are the three laws of algorithm recursion.

Have you noticed that it always seems to be sets of three laws when it comes to technology? By the way, if you haven’t read I, Robot or the Foundation Trilogy by Isaac Asimov, give it a go. They’re fantastic.

Anyway, here are the three laws of algorithm recursion:

I. A recursive algorithm must have a base case.

II. A recursive algorithm must change its state and move toward the base case.

III. A recursive algorithm must call itself, recursively.

8. How do you see yourself growing as a web developer?

Honestly if you compare where I am now to where I was eight weeks ago, it’s like night and day. I can whip-up websites so much more elegantly and quickly, and I continue to be pushed to create more complex structures. I am getting excited about what I’m building, and want to know more. It’s a lot, but it’s showing real, tangible results. I’m excited to see where the road goes.

--

--