Skip to content

Instantly share code, notes, and snippets.

;(function(){
window.myObject = {
sayHello: function () {
console.log('Hello world');
}
}
myObject.sayHello();
}());
;(function(){
window.myObject.prototype = {
sayHello: function () {
console.log('Hello world');
}
}
myObject.sayHello();
}());
<ul>
<li>Item 1</li>
<li>Item 2</li>
.
.
.
<li>Item 10,000</li>
</ul>
Given the above, write some code that would console.log the list item's innerHTML when any of the list items is clicked.
<ul>
<li>Item 1</li>
<li>Item 2</li>
.
.
.
<li>Item 10,000</li>
</ul>
Given the above, write some code that would console.log the list item's innerHTML when any of the list items are clicked.
<ul id="foo">
<li>Item 1</li>
<li>Item 2</li>
.
.
.
<li>Item 10,000</li>
</ul>
Given the above, write some code that would console.log a list item's contents when any of them are clicked.
Javascript - reference https://developer.mozilla.org/en/JavaScript/Reference
Comments
Variables
- can store any value
Types
Number
String
Boolean
Object
Null
CSS
Css is for presentation
External vs Internal vs Inline
Selectors (css2) - http://www.w3.org/TR/CSS2/selector.html
Universal: *
Type: body
Descendant: body div
Child: body > div
Class: .myclass
ID: #myId
CREATE PROCEDURE geodist (IN userid int, IN dist int)
BEGIN
declare mylon double;
declare mylat double;
declare lon1 float;
declare lon2 float;
declare lat1 float;
declare lat2 float;
// At a glance you can see which global objects are being imported, these are the local variable names you will use in your script
(function(z, $) { // encapsulate in a closure
// Use strict is within scoped function so that it only applies to this code block
"use strict"; // Prevents common errors and bad practices, by catching them at runtime.
var proto; // The var that will store the reference to the prototype for our widget
/**
* Description of what the widget does
*
* @example
* z.myWidget({
(function(){
var test = function() {
},
proto = test.prototype;
proto.method = function() {
};
}());