On Github phoenix0665 / javascript
Mocha AKA LiveScript AKA JavaScript AKA ECMAScript
var number = 1;
var string = "Hello";
var boolean_value = true;
function helloWorld(){
alert("Hello World!!");
}
null undefined
var number = 1; //Number var hello = "Hello!!"; //String var boolean_true = true; //Boolean True var boolean_false = false; //Boolean False null undefined
function importantLesson(){
a = 1;
var b = 2;
}
importantLesson();
alert(a);
alert(b);
false 0 "" null undefined NaN
Eliminate all other factors, and the one which remains must be the truth.
true == true //Equals true && true //And true || true //Or !true //Not true === "true" //What? true !== "true" //What? !!"true" //What? !!!"true" //What?
var string = "Hello World!!"; //String Object var number = 10; //Number Object
function funcName(args){
//Logic
}
var funcName = function(args){
//Logic
};
funcName(args1, args2); // Dynamic Arguments
funcName(args);
(function (){
console.log("Halo!!");
})(); //Self Excuting Functions or Dog Balls
var ar = []; //Array var ar_2 = new Array(); //Bigger way to create an array
var obj = {}; //Object
var printFooBar = function(){
var foo = "foo";
var appendBar = function(){ //Closure
console.log(foo + "bar");
};
appendBar();
};
//Class
var Car = function(){
var name = null;
var setModelName = function(model){
name = model;
};
var getModelName = function(){
return name;
};
return {
setModelName: setModelName,
getModelName: getModelName
};
};
var figo = new Car();
figo.setModelName("Figo");
figo.getModelName();
Object.prototype;
debugger;
window window.history window.location window.document
var menu = document.getElementById("menu");
var showMenu = function(event){
event.preventDefault();
event.target.className = "";
};
menu.addEventListener('click', showMenu, false);
var httpRequest = new XMLHTTPRequest();
var callback = function(){
if(httpRequest.readyState === 4){
if(httpRequest.status === 200){
alert(httpRequest.responseText);
}else{
alert("Something Went wrong");
}
}
};
httpRequest.onreadystatechange = callback;
httpRequest.open("GET", "recipes/vad-pav.json");
httpRequest.send();