This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fruits = ['banana', 'orange', 'apple', 'mango']; | |
var wheresTheApple = fruits.indexOf("apple"); | |
>wheresTheApple | |
<2 | |
//This is case sensitive. if not found retuns -1 | |
var wheresTheApple = fruits.indexOf("Apple"); | |
undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//testable via console | |
var person1 = { | |
lastName : "Dear", | |
firstName : "Stuart", | |
getFullName : function () { | |
return this.firstName + " " + this.lastName; | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myNewDate = new Date(Date()); | |
//Output : undefined | |
myNewDate | |
//Output : Thu Mar 10 2016 09:57:10 GMT-0600 (Central Standard Time) | |
myNewDate instanceof Date; | |
//Output : true | |
var myNewDateString = myNewDate.toISOString(); | |
//Output : undefined | |
myNewDateString | |
//Output : "2016-03-10T15:57:10.000Z" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This will merge the contents of two or more objects into the first object | |
// I think it can also be said, can be merged aggregated into a entirely new object. | |
//target, the object will be extended, have the new properties. | |
//HTML | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-2.1.4.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//consolable | |
//1. Simple usage, on an array | |
// basically pass in an array, .each will iterate over each element in the array. | |
// here the output is the index (0,1,3), then the value ( 52, 97 ) | |
//This can get more sophisticated when passing in data from a Json file. | |
$.each([ 52, 97 ], function( index, value ) { | |
alert( index + ": " + value ); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
1. Store a open index var | |
2. You can create other vars to hold html tags to be used in final formatting | |
3. Create the array. here we have one with 4 elements | |
4. evoke your for loop | |
- I : create your sentry variable, use the same open index var you created | |
at step 1. | |
- C : While the index is less than the length property of fruits array, | |
execute the block |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. Simple array and test | |
// isAarray method will help you tell if it is actually an array.typeof only returns 'object' | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<p>The new ECMASCRIPT 5 method isArray returns true when used on an array.</p> | |
<p id="demo"></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The while statement performs a simple loop. If the expression is falsy, then the loop will break. | |
While the expression is truthy, the block will be executed. | |
*/ | |
<!DOCTYPE html> | |
<html> | |
<body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//basic switch case statement. | |
<!DOCTYPE html> | |
<html> | |
<body> | |
<button onclick="whatDayIsIt()">What day is it? </button> | |
<p id="demo"></p> | |
<script> | |
function whatDayIsIt() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A basic javascript scaffold template, considering input, the function and output. | |
<<>> are variable areas. | |
*/ | |
<!DOCTYPE html> | |
<html> | |
<body> |