Show Menu
Cheatography

COSC-3353-Cheat Sheet Cheat Sheet by

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 XMLHtt­pRe­quest object is created.
3. The XMLHtt­pRe­quest object is config­ured.
4. The XMLHtt­pRe­quest object makes an asynch­ronous request to the web server.
5. The web server returns the result containing XML document.
6. The XMLHtt­pRe­quest 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 <st­yle> element in the <he­ad> section
External - by using a <li­nk> element to link to an external CSS file
 

Firebug

* Supports breakp­oints, watches, JavaSc­ript, 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 encaps­ula­tion, by which every class inherits the methods of its parent and only needs to define things it wishes to change
Abstra­ction is a mechanism that permits modeling the current part of the working problem. This can be achieved by inheri­tance (speci­ali­zat­ion), or compos­ition. JavaScript achieves specia­liz­ation by inheri­tance, and compos­ition 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
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          AngularJS Cheat Sheet
          JavaScript Cheat Sheet
          jasmine JS testing Cheat Sheet