Skip to content

Commit

Permalink
Notes concerning get/set; other minor edits
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Oct 15, 2011
1 parent c8ac8f6 commit 307b7b5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ blockquote { margin: 20px -30px 0 0; padding: 20px;
.two-column { -webkit-column-count: 2; -moz-column-count: 2; column-count: 2; }
/* currently webkit-only */
.stroke { -webkit-text-stroke-color: red; -webkit-text-stroke-width: 1px; }
.small { font-size: 16px !important; line-height: 1.231em; }

/* Content
----------------------------------*/
Expand Down
20 changes: 10 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<!--
Rare Javascript Operators
Awesome
by Timmy Willison
WTFPL License
If you want the cool kid fonts for this preso:
Expand Down Expand Up @@ -34,7 +34,7 @@
<meta content='IE=Edge;chrome=1' http-equiv='X-UA-Compatible' />
<meta content='timmy willison personal website' name='description' />
<meta content='timmy willison' name='author' />
<title>Javascript Operators | by timmmy willison</title>
<title>Rare Javascript Operators | by timmmy willison</title>
<link href='css/main.css' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans+Mono' rel='stylesheet' type='text/css' />
<script src='js/modernizr-shim.min.js'></script>
Expand Down Expand Up @@ -178,25 +178,27 @@ <h3>Comma Operator</h3>
</li>
<li>
<h3>Operators that are keywords</h3>
<pre class='brush: js; toolbar: false'>(function, delete, get, in, instanceof, let, new, set, this, typeof, void, yield)&#x000A;&#x000A;</pre>
<pre class='brush: js; toolbar: false'>(function, delete, get, in, instanceof, let, new, set, this, typeof, void, yield)</pre>
</li>
</ul>
<br />
<p class='small'>Note: Technically, get and set are not really called anything except property descriptors in the <a href="http://es5.github.com/#x11.1.5">spec</a> and are defined within Object Initialiser/PropertyAssignment. Mozilla Developer Network <a href="https://developer.mozilla.org/en/JavaScript/Reference/Operators">also calls them operators</a>.</p>
</section>
</div>
<!-- Get Operator -->
<!-- Get -->
<div class='slide' id='get'>
<header>
<h1>The <code>get</code> operator</h1>
<h1><code>get</code></h1>
</header>
<section>
<p>Binds an object property to a function that will be called when that property is looked up.</p>
<pre class='brush:js;toolbar:false'>var o = {&#x000A; get latest () {&#x000A; return this.log.length > 0 ?&#x000A; this.log[ this.log.length - 1 ] :&#x000A; null;&#x000A; },&#x000A; log: []&#x000A;};&#x000A;o.log[0] = "wowowow!";&#x000A;o.latest === "wowowow!";&#x000A;&#x000A;</pre>
</section>
</div>
<!-- Set Operator -->
<!-- Set -->
<div class='slide' id='set'>
<header>
<h1>The <code>set</code> operator</h1>
<h1><code>set</code></h1>
</header>
<section class='smallerCode'>
<p>Binds an object property to a function to be called when there is an attempt to set that property</p>
Expand Down Expand Up @@ -231,7 +233,7 @@ <h1>Hot debate! <code>==</code> vs <code>===</code></h1>
</header>
<section>
<p>You know the difference. <code>==</code> attempts to coerce the values before comparison. So which should you use?</p>
<pre class='brush:js; toolbar:false'>0 === 0 // true&#x000A;0 == '0' // true&#x000A;0 === '0' // false&#x000A;0 == false // true&#x000A;0 == '' // true&#x000A;undefined == 'undefined' // true&#x000A;undefined === 'undefined' // false&#x000A;null == undefined // true&#x000A;null === undefined // false&#x000A;&#x000A;&#x000A;</pre>
<pre class='brush:js; toolbar:false'>0 === 0 // true&#x000A;0 == '0' // true&#x000A;0 === '0' // false&#x000A;0 == false // true&#x000A;0 == '' // true&#x000A;null == undefined // true&#x000A;null === undefined // false&#x000A;&#x000A;&#x000A;</pre>
</section>
</div>
<!-- Benchmark without coercion -->
Expand Down Expand Up @@ -318,8 +320,6 @@ <h1>Thanks</h1>
</div>
</div>
</div>
<script charset='utf-8' src='//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js' type='text/javascript'></script>
<script>!window.jQuery && document.write('<script src="js/jquery.js"><\/script>')</script>
<!-- presentation -->
<script charset='utf-8' src='js/slides.js' type='text/javascript'></script>
<!--[if lt IE 9]>
Expand Down
7 changes: 4 additions & 3 deletions js/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@
var slideshow = new SlideShow( queryAll('.slide') );

// Animate in on load (not doc ready to allow time for jsfiddle and syntax highlighting)
$(window).load(function() {
$('.presentation').addClass('animateIn').find('.slides').show();
});
window.onload = function() {
addClass( query('.presentation'), 'animateIn' );
query('.slides').style.display = "block";
};
})();

0 comments on commit 307b7b5

Please sign in to comment.