This file contains 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
<span><script>document.write(name+' '+middlename+' '+ lastname)</script></span> | |
<span><script>getQueryVariable("n");</script></span> |
This file contains 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
//*************************** | |
//sayhello.js | |
var sayhello1 = function() { }; | |
var sayhello2 = function() { }; | |
exports.sayhello1 = sayhello1; | |
exports.sayhello2 = sayhello2; | |
//index.js | |
var x = require('./sayhello.js'); | |
x.sayhello1(); |
This file contains 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 http = require("http"); | |
//Ways to print JSON per console: | |
console.log('http: '+http); | |
console.log(JSON.stringify(http, null, 4)); | |
console.log(JSON.parse(JSON.stringify(http, null, 4))); |
This file contains 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 server = require("./server"); | |
var router = require("./router"); | |
server.start(router.route); //Injecting router as parameter. |
This file contains 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 sayings = new Map(); | |
sayings.set("dog", "woof"); | |
sayings.set("cat", "meow"); | |
sayings.set("elephant", "toot"); | |
sayings.size; // 3 | |
sayings.get("fox"); // undefined | |
sayings.has("bird"); // false | |
sayings.delete("dog"); | |
sayings.has("dog"); // false |
This file contains 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
function makeIterator(){ | |
var nextIndex = 0; | |
return { | |
next: function(){ | |
return nextIndex < 5 ? { value: nextIndex++, done: false} : {done: true} | |
} | |
} | |
} | |
var it = makeIterator(); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<body> | |
<p>Please input a number between 5 and 10:</p> | |
<input id="demo" type="text"> | |
<button type="button" onclick="myFunction()">Test Input</button> | |
<p id="message"></p> | |
<script> |
This file contains 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 txt = ""; | |
var x; | |
function Person(first, last, age, sex) { //Object prototype (Object constructor function) | |
this.firstName = first; | |
this.lastName = last; | |
this.age = age; | |
this.sex = sex; | |
this.changeFirstName = function (name) { | |
this.firstName = name; |
This file contains 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 greetCurried = function(greeting) { | |
return function(name) { | |
console.log(greeting + ", " + name); | |
}; | |
}; | |
var greetHello = greetCurried("Hello"); | |
//console.log('greetHello: ' + greetHello()); | |
greetHello("Heidi"); //"Hello, Heidi" | |
greetHello("Eddie"); //"Hello, Eddie" |
This file contains 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 rect = require('./module'); | |
function solveRect(l,b) { | |
console.log("Solving for rectangle with l = " + l + " and b = " + b); | |
rect(l,b, function(err,rectangle) { | |
if (err) { | |
console.log(err); | |
} | |
else { | |
console.log("The area of a rectangle of dimensions length = " + l + " and breadth = " + b + " is " + rectangle.area()); |