Question

JS, DOM, webapplication question 1.similarities between Javascript and python/Java/C? What differences? 2.thoughts on type coercion in...

JS, DOM, webapplication question

1.similarities between Javascript and python/Java/C? What differences?

2.thoughts on type coercion in Javascript? Do you see any benefits? Any drawbacks?

3.advantages using someElement.addEventListener("someEvent", someFunction) has over someElement.someEvent = someFunction ?

4. scalability, latency, and robustness (ability to handle failure, uncertainty, stress, etc.) as key concerns in designing and implementing web applications. Explain how you think various properties of the HTTP protocol (e.g., statelessness, headers, caching) relate to or address these key concerns.

5. a basic HTTP interaction, where the initial HTML is loaded during the first request/response cycle, and then various other pieces of the page are loaded using subsequent requests/responses. advantages of loading the information this way? Why do you think the pieces are loaded using multiple requests instead of integrating all of the data into the first response?

Homework Answers

Answer #1

Answer(1):

Javascript:

  • Javascript is a scripting language which is also called an interpreted language,it can run till the correct syntax and stop where the wrong syntax met.
  • Javascript control the browser(if any problem occurs then javascript calls implicitly).
  • JavaScript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow a client-side script to interact with the user and make dynamic pages.
  • JavaScript do not create stand-alone applications.
  • Javascript is basically for client-side model.
  • JavaScript is implemented using JavaScript statements that are placed within the <script>... </script>.
  • advantages of javascript is that it can changes at runtime.

Java:

  • Java is a  simple programming language because ,the concepts of pointer which is very difficult for both learners and programmers- has been completely eliminated from java.
  • Java is a object-oriented programming language.This means java programs uses classes and objects.
  • Java is a system independent and hence its programs can run on any type of computer system available on internet.
  • Java programs are compiled to generate the byte code.This byte code can be downloaded and interpreted by the interpreter in JVM.
  • In java, use both compiler and interpreter for the execution.

Answer(2):

Type coercion is the process of converting value from one type to another (such as string to number, object to boolean, and so on). Any type, be it primitive or an object, is a valid subject for type coercion. To recall, primitives are: number, string, boolean, null.

Drawbacks:

Since JavaScript is a weakly-typed language, values can also be converted between different types automatically, and it is called implicit type coercion. It usually happens when you apply operators to values of different types.

Benefits:

It's really very simple. When you ask a value to work with an operator it does not respect (like adding an object to a number), or when you ask two values that don't work with each other to work with each other (adding a number and a string), JavaScript tries to convert either or both types to make it work.

Answer(3):

  • The newest type of event mechanism is defined in the Document Object Model (DOM) which provides browsers with a new function-addEventListener().
  • Inside the addEventListener() function, we specify two parameters — the name of the event we want to register this handler for, and the code that comprises the handler function we want to run in response to it.
  • This isn't significant for simple, small programs, but for larger, more complex programs it can improve efficiency to clean up old unused event handlers.
  • Can add multiple listeners of the same type to elements if required. For example, it can call addEventListener("someEvent",someFunction) on an element multiple times, with different functions specified in the second argument.

Answer(4):

Stateless:

The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocol for distributed, hypertext information systems. This document defines HTTP caches and the associated header fields that control cache behavior or indicate cacheable response messages.

HTTP is typically used for distributed information systems, where performance can be improved by the use of response caches. This document defines aspects of HTTP/1.1 related to caching and reusing response messages.

Caching:

An HTTP cache is a local store of response messages and the subsystem that controls storage, retrieval, and deletion of messages in it. A cache stores cacheable responses in order to reduce the response time and network bandwidth. Any client or server may employ a cache, though a cache cannot be used by a server.

Headers:

A response to the HEAD method is identical to what an equivalent request made with a GET would have been, except it lacks a body. This property of HEAD responses can be used to invalidate or update a cached GET response, if the more efficient conditional GET request mechanism is not available (due to no validators being present in the stored response) or if transmission of the representation body is not desired even if it has changed.

Answer(5):

  • Before, go into what happens when a webpage is requested, let's look at what makes a webpage get requested in the first place.
  • The most common way a webpage is requested is when a link is clicked, but requests also occur when a page is refreshed, or when a url is typed into a browser.
  • The moment when a webpage is requested is also called "navigation start".
  • It is basically the moment where the whole process of displaying a page begins.
  • When a linked is clicked a request is made for a document.
  • Then file gets requested using a system called HTTP.
  • At this point we do not need to understand HTTP, we just need to understand that a web browser asks for the file from a web server.
  • The web server then provides the file to the web browser.
  • The response is simply the browser receiving the thing it had requested.
  • If this were a simple webpage (only HTML) the request and response stage of the page load would be complete.
  • These are called resources and in order to display the webpage the web browser must get those page resources as well.
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT