This is the third and probably my final post about 70-480 exam: Programming in HTML5 with CSS and Javascript. You need to be familiar with Javascript and Jquery for the exam. I am pointing a few things about Javascript on this article. And also, this is the follow-up of the post series “What I learned while preparing for the Microsoft 70-480 exam“.
Table of Contents
Javascript
- Form post sends form data as a query string. QueryString is limited in size by the web browser and web server you use. For example, when using Internet Explorer and Internet Information Server (IIS), the limit is 1,024 characters.
- Array Object’s Method
[0,1,2,3,4,5].slice(1,3) => [1,2] ————- doesn’t returns end tag
[0,1,2,3,4,5].splice(1,3, “add as”, “much as”, “you want”) => [1, 2, 3] and main array change to 0,add as,many as,you want,4,5
- Capturing and Bubbling
When the button is clicked, the capture process takes place where the click event is triggered on the document object, the HTML object, the body object, the hyperlink, and, finally, on the button object. Next, the bubble process takes place where the click event is triggered on the hyperlink object, the body object, the HTML object, and, finally, on the document object
btn.addEventListener('click', function(e){}, false);
addEventListener(eventType,
functionHandler,
[true-capturingPhase | false-bubblingPhase(default)])
- inline event subscription is added to the bubbling process
- e.preventDefault() -> Prevent default behavious
- e.stopPropogation() -> prevent bubble up
this
- The this keyword references the object that caused the event.
- The this keyword provides a reference to the owner of the function.
- When a function is invoked on or through an object, that object is the invocation context (aka this) for the function
Keyboard events
- the keyboard event object has the which ;
var charStr = String.fromCharCode(e.which);
Promise
- promise object can be in one of three states: pending, resolved, or rejected
- When you need to create a promise object whose state is resolved, use the $.when() method.
- The deferred object is a wrapper for the promise object. The deferred object provides control of the promise object, which is read-only.
- The promise object has the done, fail, always, and progress methods that accept a function parameter, which enables you to subscribe to the state change. The then() method on the promise object enables you to subscribe to done, fail, and progress.
- The subscription functions execute a maximum of one time.
- The state method can be used to get the current state of the promise object.
- The promise object’s pipe method chains asynchronous operations.
- The deferred object’s resolve and resolvewith methods indicate successful completion. The deferred object’s reject and rejectwith methods indicate a failed operation. The deferred object’s notify and notifywith methods update the progress.
- The name of all functions that perform asynchronous calls should end with Async, and these functions should always return a promise object.
- Use the $.when() method to monitor the completion of many parallel asynchronous calls.
- Chained and parallel asynchronous operations automatically pass failure and progress to the end of the chain.
- Call “notify” on the deferred object to indicate a change in progress
Misc
- You can stop a web worker by calling the worker.terminate() method from the creator or calling the close() method inside the worker itself.
- The WebSocket protocol is a web technology that provides full-duplex communications over a single TCP connection.
- If you do not specify a section name, by default the CACHE section is assumed on AppCache
- Web storage allows upto 5mb date and (10mb data IE) on client
- Cookies allow 4kb
- Define a function in constructor. var f = new Function(“x”, “y”, “return x * y;”); Last arg is body
- These statements are true: null == undefined, ‘’ == 0 , ‘123’ == 123
- defineProperty: If a descriptor has both value or writable and get or set keys, an exception is thrown.
- parse: If you return undefined for a property, the property is removed from resulting object
- Existing properties in objects frozen with freeze()are made immutable. Objects sealed with Object.seal() can have their existing properties changed.
- An object inherits properties from its prototype, even if the prototype changes after the object is created
- document’s DOMContentLoaded event fires earliest Load is the last
- JavaScript Null-Coalescing Operator ||: answer = x || someDefault;
- Prototype doesn’t have access to private variables
- toDataUrl() can be use as image uri
Drag API
- Dragged element events: dragstart, drag, dragend
- Drag item drop events: dragenter, dragover, dragleave, drop
XMLHttpRequest
- Get file asynchronously
- Assign a new instance of XMLHttpRequest to xhr
- Register a handler for event onreadystatechange
- Invoke xhr.open(GET/POST, url, true)
- Invoke xhr.send([data for POST])
- Xhr done=4, open=1,loading=3, headersReceived=2
Jqyery
- ~= searches for the word (term delimited by spaces) in all text
- ^= searches for the term at the beginning
- $= searches for the term at the end
- != searches for non-matches
- Next Siblings (“prev ~ siblings”)
- Next Adjacent selector (“prev + next”) — All elements that are immediately preceded by a sibling “prev”
- Most jQuery functions return arrays
- Jquery :has check matching element that has an element with has a tag
Useful links
- this
- JavaScript Inheritance
- Object.prototype
- JavaScript Closures
- JSON.parse
- JSON.stringify
- Event returnValue
- Event – cancelBubble
- serializeArray
- jQuery.ajax
- Canvas getContext
- addEventListener
- workers
- audio
- Web APIs
Conclusion
I have noted these links and points to skim through on my exam day while preparing for the exam. And honestly, it helped. I have included the only javascript things here. Eventually, I have added three articles to share my cheat sheet for the 70-480 exam: Programming in HTML5 with Javascript & CSS3. And they are
- CSS3 – What I learned while preparing for the Microsoft 70-480 exam
- HTML5 – What I learned about HTML5 elements while preparing for the Microsoft 70-480 exam
- Javascript – What I learned while preparing for the Microsoft 70-480 exam – js
What do you think about these articles? What did I miss? Please let me know if I could improve anything. If you enjoyed these notes, please share it with your colleagues and friends! And you can also connect with me on twitter or LinkedIn. I would be happy to hear from you.