Cheatography
https://cheatography.com
One page cheat sheet for COSC-3353 midterm 2
JavaScript
// Define a new class
function Person() {}
// Create a new instance
var person1 = new Person();
// Inheritance
Person.prototype.walk = function() {
alert('Walking!');
};
|
Simple Alert
<html>
<body>
<script type="text/javascript">
alert('Hello JavaScript!');
</script>
</body>
</html>
|
Simple JavaScript
<html>
<body>
<script type="text/javascript">
alert('Hello JavaScript!');
document.write('JavaScript rulez!');
</script>
</body>
</html>
|
|
|
Steps of Ajax Operation
1. A client event occurs. |
2. An XMLHttpRequest object is created. |
3. The XMLHttpRequest object is configured. |
4. The XMLHttpRequest object makes an asynchronous request to the web server. |
5. The web server returns the result containing XML document. |
6. The XMLHttpRequest object calls the callback() function and processes the result. |
7. The HTML DOM is updated. |
Accessing Elements
// By Id
document.getElementById("some_id");
// By class name
document.getElementsByClassName("some_class");
// By tag name
el.getElementsTagName("img");
|
CSS
Inline - by using the style attribute inside HTML elements |
Internal - by using a <style> element in the <head> section |
External - by using a <link> element to link to an external CSS file |
|
|
Firebug
* Supports breakpoints, watches, JavaScript, CSS, HTML
* Useful for CSS and HTML
* Edit documents in realtime
* Shows how CSS rules apply to elements
* Shows Ajax requests and responses
* Firebug is written mostly in JavaScript |
Notes
This is called encapsulation, by which every class inherits the methods of its parent and only needs to define things it wishes to change |
Abstraction is a mechanism that permits modeling the current part of the working problem. This can be achieved by inheritance (specialization), or composition. JavaScript achieves specialization by inheritance, and composition by letting instances of classes be the values of attributes of other objects. |
Just like all methods and properties are defined inside the prototype property, different classes can define methods with the same name; methods are scoped to the class in which they’re defined. This is only true when the two classes do not hold a parent-child relation |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by foobar