Javascript, DOM, & JQuery Flashcards

1
Q

What is Javascript?

A
  • Enhance client side of SAAS applications.
  • It is embedded in all browsers.
  • It can be triggered by user events.
  • It can be triggered by Asynchronous server responses.
  • It can design and modify the DOM.
  • Interpreted and dynamically typed.
  • No classes, but has prototypal inheritance. it is Object -Oriented though.
  • Each HTML page gets its own JS Global object. So each page must separately load its JS file.
  • No instance methods, just properties.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is JQuery?

A

It is like Rails for Ruby. A very easy framework for Javascript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is AJAX?

A

Asynchronous Javascript XML.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What Are XmlHttpRequests?

A

XmlHttpRequests separate content from server and rendering that content, you could make requests to server in the background.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the DOM?

A

There is a DOM which is the Document Object Model. A set of data structures for what the user is seeing. It is language independent. Browser parses HTML or XML to the DOM. The browser provides the functions to javascript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is graceful degradation in javascript?

A

Browsers with JS disabled should be able to use your ap. Javascript problems should not prevent your application from working. Conditionally show page elements with javascript.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Javascript client side code can interact with the HTML page elements because this functionality is ____.

A

Part of the Javascript language and part of the JSAPI. It is not, however, part of the browser.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the Javascript Hashes?

A

Unlike Ruby, the keys pretty much have to be strings. Value can be pretty much any javascript object. Quotes are always legal. if you use JSON you have to have quotes. If only using javascript, then you don’t need it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is var in javascript?

A

var restricts the variable to the scope of where it is declared. Or if there are no methods, then it is in the global scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Functions in javascript?

A

Also closures = scope of where you first define will be in scope of where it runs.

First class objects in javascript - means you can do anything to it that you could do to like a string.

Variables in functions stay in the functions. Common pattern is to pass functions to other functions.

Functions are actually a type.
var make_func = function() {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is The Global Object?

A

Browser provided global object that provide properties to javascript. this in the context without any receiver refers to the global object. Remember this for failures. The Global object represents the document that got loaded and access to JSAPI is through this object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Can SOFA be applied to Javascript?

A

Yes. Short Functions, etc. Keep code separate from HTML.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

If you manually open two separate browser windows, can javascript code loaded into one of those windows affect the other window?

A

No, because each window has is own global object and therefore its own copy of the interpreter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Can the properties of an object be functions?

A

Yes you can have an object with properties as functions.

R = {};
R.setup = function() {};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Find the False Statement of javascript functions?

a. they can be anonymous
b. they always return a value
c. They can execute concurrently with other functions
d. they can be passed a function as argument

A

They cannot execute concurrently with other functions. Javascript is single threaded.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the prototype structure of Javascript?

A

Each newly created object gets a prototype, obj.__proto__.
When Slot lookup fails in an object, its prototype is consulted, and so on up the chain. So object inherits both value-slots and function slots.

17
Q
What is the output?
var foo = {name: "foo", one: 1, two: 2};
var bar = {two: "two", three: 3};
Object.setPrototypeOf(bar, foo)

bar. one
bar. three
foo. name;

A

Simple prototype inheritance.

bar. one => 1
bar. three => 3
bar. two => 2
foo. name => “foo”

Could also run var bar = Object.create( foo ); to set prototype.

18
Q

What are constructor Style Functions?

A

If you call a function with new, then it creates a new object (this) whose prototype is whatever the function’s prototype is. Then it returns the new object. It is like calling a constructor.

Call a function on that object. The inside those functions, this refers to that object (receiver).

Call a function without the receiver, then this is referred to the global object. This is bad news sometimes.

19
Q

What happens here?
var b = Movie(‘Juno’, 2007, ‘PG-13’)
b.full_title()

A

since you did now have the new key word, then this will return an error. Full_title has this keyword within it.

20
Q
var Square = function(side) {
this.side  = side;
this.area = function() {
return this.side * this.side;
}};
What do you call to get 9?
A
var p = Square;
(new P(3)).area();
Remember you must call are with paranthesis and you must have the 'new' keyword or else this in the Square refers to the global object.
21
Q

What is JQuery For?

A

Lets you access the JSAPI of the browser using its framework. Use the $ allias for JQuery.

22
Q

Polymorphic function?

A

Does different things depending on what is called on it. JQuery is polymorphic.

23
Q

What do these evaluate to?
$(‘#movies’)
$(‘.heading’)
$(‘table’)

A

id = movies
css class = heading
element type = table.

These are equivalent to $(window.document).find(selector).

Will return many elements sometimes, but not an array. You can iterate though.

24
Q

Can you do more or less than the window.document call with a JQuery Call?

A

You can do more with JQuery than the document.

25
Q

Should you not validate on the server when you validate with javascript?

A

No you should always validate on the server cause they might have javascript disabled.