2

I just took a quiz in a computer science class and I got the following question:

Answer the question whether True or False:

The Javascript file is being interpreted by the server before being sent to the client browser window.

I put false, as Javascript in this case because I thought the Javascript file was interpreted on the client side. However, the "correct answer" was true. If someone could explain this I would appreciate it.

  • 1
    no the browser interprets JS, after it's been received from the server – Velimir Tchatchevsky Sep 14 '18 at 19:39
  • 3
    I agree with your answer. You should ask your professor about what he or she has in mind. – Code-Apprentice Sep 14 '18 at 19:39
  • 1
    The JS file *could* be interpreted by the server before being sent. Although that relies on what exactly "interpreted" means to somebody but even with the widest of definitions it's still not always the case. I'd also suggest asking the professor to clarify. – VLAZ Sep 14 '18 at 19:42
  • 1
    Sounds like a BS trick question. For the *longest* time JavaScript was client-side only, Only with the advancement of node.js and related libraries did it move also onto the server. – j08691 Sep 14 '18 at 19:43
  • @undefined the question states `before being sent to the client browser window`, so it doesn't seem like it's a server-side JS file. It does still depend, though - you could manipulate a JS file before sending it. For example, you could gzip it or bundle it on the fly. Or perhaps even construct it on the fly. Not often but it can be done. So, it does depend. – VLAZ Sep 14 '18 at 19:44
  • Can you provide the full question. From what you have given the correct answer would be false. But it sounds like there may be some context you are missing here. – bhspencer Sep 14 '18 at 19:48
  • @vlaz - gzipping or bundling a js file is often done (although usually not at request time), but I would hardly call that "interpreting" the js. – Ted Hopp Sep 14 '18 at 19:48
  • Minifying or bundling would usually be done as part of the "compilation" phase of the JS. Rarely done at request time. – bhspencer Sep 14 '18 at 19:49
  • @bhspencer This was the full context of the question. This is all they gave. :I – JJ Thompson Sep 14 '18 at 19:49
  • A question that should have a boolean answer should not need so many _interpretations_! – undefined Sep 14 '18 at 19:50
  • Well if that is it without any additional info I would say your professor has made a mistake. – bhspencer Sep 14 '18 at 19:51
  • @TedHopp to be honest, I'd agree. But as I said, the definition of "interpreting" could vary from person to person. Software engineers are notorious for being into technicalities. [Teachers in the field doubly so](https://stackoverflow.com/questions/52264638/is-main-a-valid-java-identifier). – VLAZ Sep 14 '18 at 19:52
  • @vlaz in CS "interpreting" means a very particular unambiguous thing. The general case when sending a JS file to a browser the server does not interpret it. – bhspencer Sep 14 '18 at 19:53
  • @bhspencer and that doesn't mean somebody couldn't be wrong in their usage of the word. Check the linked question. – VLAZ Sep 14 '18 at 19:55
  • 1
    Is the class about front end development or back end development? If it's a Node.JS class, then the answer might well be true. If it's a JS/HTML class, then it's probably false. – nixkuroi Sep 14 '18 at 20:22
  • i would refuse to answer this question without mention the environment. – Nina Scholz Sep 14 '18 at 21:42

1 Answers1

2

JavaScript primarily runs in the browser. Though the quiz could've been referring to a templating engine, in that case, it does evaluate some JS and generates an HTML page. Or perhaps something like server-side rendering with React. In most cases, a JS file for the client is not interpreted by the server.

So unless your class was learning templating engines recently I disagree with this answer too. Ask your professor and let us know why or if it was just an error.

CodeDraken
  • 896
  • 4
  • 12