Skip to content

Instantly share code, notes, and snippets.

View AkimaLunar's full-sized avatar

Aaron Carmin AkimaLunar

  • Vancouver Island, BC
  • 07:31 (UTC -07:00)
View GitHub Profile
@AkimaLunar
AkimaLunar / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
.button {
// general styling for all buttons
// …
// Generates modifier classes for .button
@each $theme, $color in $ui-colors {
&--#{$theme} {
background-color: $color;
color: transparentize($white, .2);
}
&--#{$theme}:hover,
// Colors
$color-facebook : #3B5998;
$color-twitter : #55ACEE;
$color-pinterest : #CC2127;
$color-youtube : #E52D27;
$social-media-icons: (
facebook : $icon-facebook,
twitter : $icon-twitter,
pinterest : $icon-pinterest,
// UI Colors
$color-robin : #8FCCCC;
$color-vista : #79D1AD;
$color-mandy : #e67478;
$color-apricot : #ed8864;
$color-eastside : #9279c3;
// UI Colors Map
$ui-colors: (
default : $color-robin ,
function wisePerson(wiseType, whatToSay) {
return 'A wise ' + wiseType + ' once said: "' + whatToSay + '".';
}
function shouter(whatToShout) {
return whatToShout.toUpperCase() + '!!!';
}
function textNormalizer(text) {
return text.trim().toLowerCase();
function computeArea(width, height) {
return width * height;
}
function celsToFahr(celsTemp) {
return celsTemp*9/5+32;
}
function fahrToCels(fahrTemp) {
return (fahrTemp-32)*(5/9);

Variable Scope

What is scope? Your explanation should include the idea of global vs. local scope.

Scope defines the visibility of variables. In JavaScript, variables can be in either global or local scope. Global variables are accissible from anywhere in the application. Local variables declared with a var keyword are visible only within a function block. Local variables declared with let keyword are limited further to their respective block, statement or expression

Why are global variables avoided?

You or another developer can accidentally write code that mutates or overwrites a global variable from a local scope.

Explain JavaScript's strict mode

JavaScript's strict mode allows the developer to opt-in a more restrictive version of JavaScript. Mistakes that would normally just silently fail, would throw an error in the strict mode.