UI Engineer Flashcards
What’s a closure? Why use it?
A closure is when an inner function accesses variables just outside its scope. You can create private variables & functions with closures.
What’s “undeclared” versus “undefined” re: variables?
Undeclared does not exist yet. If you give a value to an undeclared variable, it puts it on the global object. To avoid that, declare it first with var. A variable only declared will still be undefined until it is given a value.
What are cookies, localStorage, and sessionStorage?
Cookies are the legacy way browsers keep user data in the form of a key value pairs. It has a built in convention for expiration. LocalStorage & sessionStorage are newer APIs that are in some ways easier to use and without the limitations cookies have. LocalStorage can keep a key value pair, but without built in expiration. SessionStorage can also keep a key value pair but they expire with the session.
What’s JSONP? Why is it not considered AJAX?
Stands for JSON w/ padding. The “padding” is the call to function that receives the data as its first argument.
It is not AJAX because it does not use the XHR API. It’s really just remote JavaScript. It’s easy and can be used cross domain without issue. Because of that, there maybe valid security concerns.
What is “Standards” versus “Quirks” mode?
A browser has both. With a valid doctype, it will render in standards mode based on W3C guidelines. Without a valid doctype it will render in quirks mode without strict regard for W3C guidelines. Sometimes invalid markup will trigger quirks mode.
Why not extend built in JavaScript objects?
Avoid it for future proofing and name collision. The Prototype library extended Function with a “bind” method. At a later point ECMA5 introduces the same method on Function, but with some variation making it a breaking change for those using the library.
Also, it can effect looping through enumerable properties of an object in a negative or unexpected way.
What is the JS module pattern?
Uses a closure to create a protected scope for local variables and functions while still maintaining access to globals. A return value exposes public methods to indirectly access protected logic.
What is a doctype?
It is a preamble that establishes the standard format a browser uses for rendering its content.
What are the building blocks of HTML5?
Semantically, the building block are: header, footer, nav, article, section, & aside.
But more exciting are the new APIs, audio, video, canvas…
Rich web content without flash.
What’s GET & POST?
The two most common form methods.
GET - requests data from a resource.
POST - submits data to a resource.
What is an anonymous function?
It is an unnamed/undeclared function.
They’re most commonly used as arguments to other function calls. For example, callbacks.
What is JS inheritance?
Unlike classical inheritance, JavaScript is prototype-based. Instead of inheriting from classes, objects inherit from other objects using the prototype chain.
What is the box model?
It’s the box that wraps around HTML elements. It’s made up of margins, borders, padding and then content; in that order.
What is JavaScript and Jquery?
JavaScript is the standard programming language of the web.
Jquery is library written in JavaScript. It makes DOM manipulation easy.
What is an undeclared, undefined, & null variable?
Undeclared variables don’t exist yet. To make it exist declare it with var. If only declared, a variable remains undefined. To make it defined prior to its final value, set it equal to null. Null means nothing, but is an actual value.