Skip to content

Instantly share code, notes, and snippets.

View defields923's full-sized avatar

Devin F. defields923

View GitHub Profile
@defields923
defields923 / jsbin.fuqawu.js
Last active December 4, 2016 06:03 — forked from anonymous/index.html
LoopingLooping studies// source https://jsbin.com/fuqawu
// -----Loops----- //
/* For loops are great tools for iterating over individual elements within an array
to work with them. A for loop has three sections within its proceeding parentheses: an
initialization, conditional statement, and a final expression. The initialization phase
usually declares a variable. The conditional statement phase tells the loop when to stop,
and the final expression performs an action at the end, usually incrementing or
decrementing a counter: */
"use strict";
@defields923
defields923 / jsbin.xitune.js
Last active December 4, 2016 04:11 — forked from anonymous/index.html
Control FlowControl flow studies// source https://jsbin.com/xitune
// -----Control Flow----- //
/* If statements are used in Javascript to make decisions--whether to execute a following
code or not. An if statement first evaluates the boolean within parentheses and then executes
the code within curly braces if the boolean was true: */
"use strict";
if (typeof "Is this a string?" === "string") {
console.log("Yup, it was a string");
@defields923
defields923 / jsbin.pucoqu.js
Last active December 4, 2016 04:26 — forked from anonymous/index.html
OperatorsOperators studies// source https://jsbin.com/pucoqu
// -----Operators----- //
/* In Javascript, operators can perform a number of tasks. Unary operators take only one value: */
"use strict";
console.log(typeof 10); // "typeof" is a unary operator
console.log(!true); // "!" flips the following value, logging false
/* Binary operators can be placed between two values and return a new value: */
@defields923
defields923 / jsbin.jimiku.js
Last active December 4, 2016 00:12 — forked from anonymous/index.html
Undefined, Null, NaN, InfinityUnd, Nu, NaN, Inf studies// source https://jsbin.com/jimiku
// -----Undefined, Null, NaN, Infinity, -Infinity----- //
/* Undefined and null are both special values that signify the absence of meaningful
data. Undefined is considered its own data type, but null is considered an object by Javascript,
which can be misleading. Null, more specifically, should represent the nonexistence of
something. */
"use strict";
console.log(typeof undefined);
@defields923
defields923 / jsbin.gisuki.js
Last active December 3, 2016 23:49 — forked from anonymous/index.html
FunctionsFunctions studies// source https://jsbin.com/gisuki
// -----Functions----- //
"use strict";
name(); // ignore me for now *wink-wink*
/* Functions are first-class objects, "subprograms" and reusable code that can be "called" or
"invoked" at later times to produce a value or side-effect. To declare a simple function, first
begin with the keyword "function" followed by the name, parentheses, and curly braces. The
function body within the curly braces contains the sequence of statements to be executed when it
@defields923
defields923 / jsbin.niyoqew.js
Last active December 3, 2016 01:51 — forked from anonymous/index.html
ObjectsObjects studies// source https://jsbin.com/niyoqew
// -----Objects----- //
/* An object, like an array, is a container for data, but an object stores key/value pairs
with curly braces. Almost every is considered an object except primitive values, including
strings, numbers, booleans, null, and undefined. Objects can be created in three ways: */
"use strict";
var obj1 = {}; // the literal method, creating an empty object assigned to the variable
console.log(obj1);
@defields923
defields923 / jsbin.dikixab.js
Last active December 3, 2016 01:17 — forked from anonymous/index.html
ArraysArray studies// source https://jsbin.com/dikixab
// -----Arrays----- //
/* Arrays are list-like objects with a large number of mutational and accessible
methods. They can be assigned to variables and are enclosed with squar brackets: */
"use strict";
var exArray = ["I'm element 0", "I'm element 1", "Care to guess?"];
/* As the example demonstrates, arrays are zero-based indexed, and elements can
@defields923
defields923 / jsbin.bameke.js
Last active December 1, 2016 21:39 — forked from anonymous/index.html
BooleansBoolean studies// source http://jsbin.com/bameke
// -----Data Types: BOOLEAN----- //
/* A boolean is a data type that has one of two mutually
exclusive values: true or false. A boolean acts like an "on-off"
switch, where "true = on" and "false = off." They are used in
conjunction with comparion operators to evaluate expressions.
When comparing letters and non-alphnumeric characters, the
character will resolve to its Unicode number, which will be
used to make the comparison. When comparing strings, Javascript
compares individual characters from left to right. */
@defields923
defields923 / jsbin.bimiqe.js
Last active December 1, 2016 21:11 — forked from anonymous/index.html
StringsStrings studies// source http://jsbin.com/bimiqe
// -----Data Types: STRING----- //
/* Strings are character or textual data strung together enclosed
by either single or double quotes. */
var stri = "I'm a sequence of character data!";
console.log(stri);
/* Almost anything can be put within a string with the exception
of a number of special characters, such as the newline "\n" and
@defields923
defields923 / jsbin.waseni.js
Last active December 1, 2016 02:54 — forked from anonymous/index.html
NumbersNumbers studies// source https://jsbin.com/waseni
// -----Data Types: NUMBER---- //
/* Numbers are simply numeric values used for arithmetic.
Whole integers and fractional numbers using decimal points
are permitted. With numbers of exceptional size, scientific
notation using "e" (exponent) is allowed: */
// 2.998e8 = 2.998 × 10 to the 8th power = 299,800,000
// -----Using Numbers for Arithmetic----- //