Get Started. It's Free
or sign up with your email address
JavaScript by Mind Map: JavaScript


1.1. Pure implementation

1.1.1. XMLHttpRequest Methods abort() getAllResponseHeaders() getResponseHeader(headerName) open(method, URL, async, userName, password) send(content) setRequestHeader(type, value) Fields readystate responseText responseXML status

1.2. Frameworks

1.2.1. GWT

1.2.2. Dojo

1.2.3. jQuery

2. History handling

2.1. Native

2.1.1. History object Fields current next prev length Methods forward() back() go(link)

2.1.2. Managing In jQuery its used using iframe and timert

3. DOM

3.1. See native support

4. Inside

4.1. Browser events

4.1.1. Types DOM events onclick mouseover Window events resize Other events load(handler) readystatechange

4.1.2. Working with addEventListener removeEventListener detachEvent Use event as a parameter in fuction

4.1.3. Event bubbling Parents handle child events Slows down gwt code and huge widget hierarchies

4.1.4. Methods stopPropagation to protect from handle bubbling preventDefault prevent default action handling (example: anchor click not redirects to URI)

4.1.5. DOM standart First - capture event Then - bubble ! not all the browsers use this standart

4.1.6. Prevent unnecessary bubbling if ( == this) {} event.stopPropagation()

4.1.7. Removal unbind('name') Example: unbind('click')

4.1.8. Rebind bind('name', handlerFunction)

4.1.9. Simulating user actions trigger(eventName) Example: trigger('click')

4.1.10. Hierarchy 4 Model registration models inline traditional w3c Microsoft Event access function(event) Cross-browser 2 Event order models Event capturing Even bubbling

4.2. Execution context

4.2.1. call() and apply() methods Example: someFunction().call(objectB) 'this' will now link to objectB instance

4.3. Event loop

4.3.1. Thread by browser checking event states

4.3.2. Executed using event queue

5. Objects

5.1. Window

5.1.1. Methods onload onresize onkeyup onerror

5.1.2. Global scope (browser-based JS)

5.1.3. Implemented as JS object

5.1.4. Fields parent screen window current window

5.2. Document

5.2.1. Reference to HTML DOM els

5.2.2. Not JS

5.2.3. Fields cookie Usage: window.document.cookie activeElement focused element anchors body defaultCharset documentElement link to itself location changing forces refresh URL read-only parentWindow referrer scripts width

5.2.4. One instance for web page

5.2.5. Methods ready DeferredBinding analog

5.3. Hierarchy

5.3.1. Navigator MimeType Window Frame History Location Document Plugin

5.4. Functions

5.4.1. Function closure Acts as anonymous class in java

6. Server side

6.1. Node.js

6.1.1. library

6.1.2. Event-driven

6.1.3. Non-blocking

6.1.4. Being used eBay Microsoft

6.1.5. May be used Creating web servers HTTP servers are very easy

6.1.6. Execution node program.js

6.1.7. Objects global process console

6.1.8. STDIO using console object

6.1.9. Other features Buffers DNS work HTTP utils FS SSL ...

7. Language notes

7.1. No {} scope like in other langs

7.2. OOP

7.2.1. Instead of class/instance - Object

7.2.2. Instead of super: __proto__

7.3. Functions have an attribute called prototype

7.3.1. Immutable

7.4. All variables are function-local. Even in loops!

7.5. Also has gc

7.6. Functions are classes

8. Browser compatibility

8.1. Events


8.2. Autohead

8.2.1. Automatical creating 'head' element even if it doesn't exist

8.2.2. Disabled in android, iPhome, Opera 8 That's why adding script to head from code may fail here

8.3. When you modify body from script which isn't a part of it - you get 'Operation aborted' in IE

8.4. Correct insertion of script

8.4.1. var first = document.getElementsByTagName('script')[0]; first.parentNode.insertBefore(js, first);

8.5. IE

8.5.1. GET caching in IE Usage of hashes in links set expire flag

8.5.2. Operation aborted Change parent while it hasn't been constructed yet

8.5.3. Doesn't have capturing

8.5.4. Doesn't have w3c event registration mechanism (addEventListener)

9. Debug

9.1. Chrome should be started with debug option

10. Patterns

10.1. See JavaScript MVC

11. Other notes

11.1. window.onload may be called when DOM hasn't been constructed

11.1.1. Use document.ready

11.2. To prevent from default event handling use return false;

11.2.1. Cases like a href="bla" and $(a).click(function() {bla2})

12. jQuery

13. JavaScriptMVC

13.1. MVC mechanism

13.1.1. jQueryMX $.Model encapsulates app model $.View $.Controller

13.2. Dependency management

13.2.1. StealJS Loads several modules, prevents from reloading Single load point Usage steal('widgets/tabs.js', './style.css', function(){ $('#tabs ).tabs(); });

13.3. Functional, unit testing

13.3.1. FuncUnit Asserts test("counter", function() { ok(Conctacts.first().name, "there is a name property"); equal(Contacts.counter(), 5, "there are 5 contacts"); }); Methods setup test teardown

14. Engines

14.1. Google v8

14.1.1. Used in Chrome

14.2. Main features

14.2.1. Memory allocation

14.2.2. Compile

14.2.3. GC

15. Tools

15.1. yui compressor

15.1.1. Obfuscates and compressed short names css compression