JS Closures an der LMU München

CitySTADT: Augsburg

CountryLAND: Deutschland

Kommilitonen im Kurs JS Closures an der LMU München erstellen und teilen Zusammenfassungen, Karteikarten, Lernpläne und andere Lernmaterialien mit der intelligenten StudySmarter Lernapp.

Schaue jetzt auf StudySmarter nach, welche Lernmaterialien bereits für deine Kurse von deinen Kommilitonen erstellt wurden. Los geht’s!

Kommilitonen im Kurs JS Closures an der LMU München erstellen und teilen Zusammenfassungen, Karteikarten, Lernpläne und andere Lernmaterialien mit der intelligenten StudySmarter Lernapp.

Schaue jetzt auf StudySmarter nach, welche Lernmaterialien bereits für deine Kurse von deinen Kommilitonen erstellt wurden. Los geht’s!

Lerne jetzt mit Karteikarten und Zusammenfassungen für den Kurs JS Closures an der LMU München.

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

What happens when you assign a variable that has not yet been declared?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

In a traditional compiled-language process, what is the correct order of the three main steps a program will undergo before executing?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

Which of the following is the responsibility of Scope?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

wo distinct actions are taken for a variable assignment such as var a = 2;

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

Why does it matter whether we call the look up LHS or RHS? (HS=hand side)

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

What is the difference between an LHS lookup and an RHS lookup?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

How does traversing for nested Scope works?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

What will be logged to the console upon execution of the code below:
foo();
var foo = function() {
console.log('hello')
}

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

What is the main fundamental concept of Delegation-Oriented Design in comparison to the traditional Object-Oriented Design?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

what do "parsed" languages have in common with "compiled" languages?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

So JS is a parsed language, but is it compiled?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

What is hoisting?

Beispielhafte Karteikarten für JS Closures an der LMU München auf StudySmarter:

JS Closures

What happens when you assign a variable that has not yet been declared?

If you try to set a variable that hasn’t been declared, you’ll either end up creating a variable in the top-level global scope (bad!) or getting an error, depending on „strict mode“ (see „Strict Mode“).

JS Closures

In a traditional compiled-language process, what is the correct order of the three main steps a program will undergo before executing?

Tokenizing/Lexing is the process of breaking up a string of characters into meaningful chunks called tokens. Parsing is the act of taking a stream of tokens and turning it into a tree of nested elements which represent the structure of the program. Code-Generation is the process of taking the tree and turning it into executable code.

JS Closures

Which of the following is the responsibility of Scope?

The Scope is responsible for maintaing a look-up list of all declared identifiers and enforcing a strict set of rules as to how these are accessible to currently executing code.

JS Closures

wo distinct actions are taken for a variable assignment such as var a = 2;

Two distinct actions are taken for a variable assignment: First, Compiler declares a variable (if not previously declared in the current scope), and second, when executing, Engine looks up the variable in Scope and assigns to it, if found.

JS Closures

Why does it matter whether we call the look up LHS or RHS? (HS=hand side)

The names matter because these two types of look-ups behave differently in the circumstance where the variable has not yet been declared (is not found in any consulted Scope). If an RHS look-up fails to ever find a variable, this results in a ReferenceError being thrown by the Engine. By contrast, if the Engine is performing an LHS look-up and arrives at the top floor (global Scope) without finding it, and if the program is not running in „Strict Mode“, then the global Scope will create a new variable of that name in the global scope.

JS Closures

What is the difference between an LHS lookup and an RHS lookup?

LHS stands for „left hand side“, and RHS stands for „right hand side“. For a = b, the RHS looks for the value of b, and the LHS looks for the location of a in memory, so that it can update its value.

JS Closures

How does traversing for nested Scope works?

Engine starts at the currently executing Scope, looks for the variable there, then if not found, keeps going up one level, and so on. If the outermost global scope is reached, the search stops, whether it finds the variable or not.

JS Closures

What will be logged to the console upon execution of the code below:
foo();
var foo = function() {
console.log('hello')
}

var foo is „hoisted“ but the function is not. By the time the engine executes the first line, var foo will have been declared, so it is not a ReferenceError. We try to call it as a function, but its value is undefined which leaves us with a TypeError.

JS Closures

What is the main fundamental concept of Delegation-Oriented Design in comparison to the traditional Object-Oriented Design?

There is no idea of parent and child, just object linkages.
Fundamentally, the prototype chain does not have a concept of „copying“ or „parent creating child“. All it does is chain objects together.

JS Closures

what do "parsed" languages have in common with "compiled" languages?
First, all compiled languages are parsed. So a parsed language is quite a ways down the road toward being compiled already. In classic compilation theory, the last remaining step after parsing is code generation: producing an executable form.
Once any source program has been fully parsed, it’s very common that its subsequent execution will, in some form or fashion, include a translation from the parsed form of the program — usually called an Abstract Syntax Tree (AST) — to that executable form.
In other words, parsed languages usually also have code generation before execution, so it’s not that much of a stretch to say that, in spirit, it’s a compiled language.
JS source code is parsed before it is executed. The specification requires as much, because it calls for „early errors“ — statically determined errors in code, such as a duplicate parameter name — to be reported before the code starts executing. Those errors cannot be recognized without the code having been parsed.

JS Closures

So JS is a parsed language, but is it compiled?
The answer is closer to yes than no. The parsed JS is converted to an optimized (binary) form, and that „code“ is subsequently executed; the engine does not commonly switch back into line-by-line execution mode after it has finished all the hard work of parsing — most languages/engines wouldn’t, because that would be highly inefficient.
To be specific, this „compilation“ produces a binary byte code (of sorts), which is then handed to the „JS virtual machine“ to execute. Some like to say this VM is „interpreting“ the byte code. But then that means Java — and a dozen other JVM-driven languages, for that matter — is intrepreted rather than compiled. That contradicts the typical assertion that Java/etc are compiled languages. While Java and JavaScript are very different languages, the question of interpreted/compiled is pretty closely related between them.
Another wrinkle is that JS engines can employ multiple passes of JIT (Just-In-Time) processing/optimization on the program’s code, which again could reasonably be labeled either „compilation“ or „interpretation“ depending on perspective. It’s actually a fantastically complex situation under the hood of a JS engine.
So what do these nitty gritty details boil down to?
Step back and consider the entire flow of a JS source program: after it leaves a developer’s editor, it gets transpiled by Babel, then packed by Webpack (and probably undergoes half a dozen build processes), then it gets delivered in that very different form to a JS engine, then that engine parses the code to an AST, then the engine converts that AST to a kind-of byte code, then that byte code is converted even further by the optimizing JIT compiler, and finally the JS VM executes the code.

JS Closures

What is hoisting?

Basically, when Javascript compiles all of your code, all variable declarations using var are hoisted/lifted to the top of their functional/local scope (if declared inside a function) or to the top of their global scope (if declared outside of a function) regardless of where the actual declaration has been made. This is what we mean by “hoisting”.

Functions declarations are also hoisted, but these go to the very top, so will sit above all of the variable declarations.

However, a key thing to note is that the only thing that gets moved to the top is the variable declarations , not the actual value given to the variable. (so it returns undefined)

what we have to remember though is that the concept of hosting is not a literal process (ie, the declarations themselves do not move to the top of the file — it is simply a process of the JavaScript compiler reading them first in order to create space in memory for them).

Recall how Chapter 1 pointed out that all identifiers are registered to their respective scopes during compile time. Moreover, every identifier is created at the beginning of the scope it belongs to, every time that scope is entered. The term for registering a variable at the top of its enclosing scope, even though its declaration may appear further down in the scope, is called hoisting.

let and const will throw reference errors and is well documented. This is because although let and const are hoisted they are not initialised until the code executes the initialising line. The time between a let or const being hoisted and initialised is commonly know as the temporal dead zone.

Gradient

Melde dich jetzt kostenfrei an um alle Karteikarten und Zusammenfassungen für JS Closures an der LMU München zu sehen

Singup Image Singup Image

Andere Kurse aus deinem Studiengang

Für deinen Studiengang an der LMU München gibt es bereits viele Kurse auf StudySmarter, denen du beitreten kannst. Karteikarten, Zusammenfassungen und vieles mehr warten auf dich.

Zurück zur LMU München Übersichtsseite

Was ist StudySmarter?

Was ist StudySmarter?

StudySmarter ist eine intelligente Lernapp für Studenten. Mit StudySmarter kannst du dir effizient und spielerisch Karteikarten, Zusammenfassungen, Mind-Maps, Lernpläne und mehr erstellen. Erstelle deine eigenen Karteikarten z.B. für an der LMU München oder greife auf tausende Lernmaterialien deiner Kommilitonen zu. Egal, ob an deiner Uni oder an anderen Universitäten. Hunderttausende Studierende bereiten sich mit StudySmarter effizient auf ihre Klausuren vor. Erhältlich auf Web, Android & iOS. Komplett kostenfrei. Keine Haken.

StudySmarter Flashcard App and Karteikarten App
d

4.5 /5

d

4.8 /5

So funktioniert StudySmarter

Individueller Lernplan

Bereite dich rechtzeitig auf all deine Klausuren vor. StudySmarter erstellt dir deinen individuellen Lernplan, abgestimmt auf deinen Lerntyp und Vorlieben.

Erstelle Karteikarten

Erstelle dir Karteikarten in wenigen Sekunden mit Hilfe von effizienten Screenshot-, und Markierfunktionen. Maximiere dein Lernverständnis mit unserem intelligenten StudySmarter Trainer.

Erstelle Zusammenfassungen

Markiere die wichtigsten Passagen in deinen Dokumenten und StudySmarter erstellt dir deine Zusammenfassung. Ganz ohne Mehraufwand.

Lerne alleine oder im Team

StudySmarter findet deine Lerngruppe automatisch. Teile Karteikarten und Zusammenfassungen mit deinen Kommilitonen und erhalte Antworten auf deine Fragen.

Statistiken und Feedback

Behalte immer den Überblick über deinen Lernfortschritt. StudySmarter zeigt dir genau was du schon geschafft hast und was du dir noch ansehen musst, um deine Traumnote zu erreichen.

1

Individueller Lernplan

2

Erstelle Karteikarten

3

Erstelle Zusammenfassungen

4

Lerne alleine oder im Team

5

Statistiken und Feedback

Nichts für dich dabei?

Kein Problem! Melde dich kostenfrei auf StudySmarter an und erstelle deine individuellen Karteikarten und Zusammenfassungen für deinen Kurs JS Closures an der LMU München - so schnell und effizient wie noch nie zuvor.