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
// AWS Comprehence | |
//http://www.jsonquerytool.com/ | |
var filteredToken = _.filter( | |
input.SyntaxTokens, | |
function(token) { | |
return token.PartOfSpeech.Tag == "PROPN" && token.PartOfSpeech.Score > 0.95; | |
}).sort(function(t1,t2){ | |
return t2.PartOfSpeech.Score - t1.PartOfSpeech.Score; | |
}).map(function(token){ | |
return { |
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 promiseRemoteData = new Promise(function(resolve,reject){ | |
// 1. Perform ASYNC operation | |
// 2. On completion of remote operation call | |
// - resolve to notify success (pass any values that is required) | |
// - reject to notify error condition | |
} |
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 getPromiseRemoteData(url){ | |
var promiseRemoteData = new Promise(function(resolve,reject){ | |
// Initiate call | |
//var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; //Uncomment this line if you are using it in node js environment. | |
// 1. Create the request | |
var xhr = new XMLHttpRequest(); | |
// 2. Create the URL | |
var delay = Math.floor(Math.random() * 9) + 1; |
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 getRemoteData(url){ | |
//var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; //Uncomment this line if you are using it in node js environment. | |
// 1. Create the request | |
var xhr = new XMLHttpRequest(); | |
// 2. Create the URL | |
var delay = Math.floor(Math.random() * 9) + 1; | |
// Open the URL |
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 printRemoteData(url, message){ | |
//var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; //Uncomment this line if you are using it in node js environment. | |
var xhr = new XMLHttpRequest(); | |
var delayedUrl = url + "?delay=" + (Math.floor(Math.random() * 9) + 1); | |
console.log(delayedUrl); | |
xhr.open("GET", delayedUrl, true); | |
xhr.onload = function(){ | |
if (message){ | |
console.log(message); | |
} |
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
console.log("Begin example - 6"); | |
// Adding of three numbers using a function | |
// Define an add function that can work for three or less arguments | |
function add(a,b,c){ | |
var d = ( (a) ? a : 0 ) + // Using ternary operator we can check the | |
( (b) ? b : 0 ) + // Truthy/Falsy of the parameter and then | |
( (c) ? c : 0 ) ; // Substitue with numeral zero so that NaN is avoided. | |
return d; | |
} |
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
console.log("Begin example - 5"); | |
// Adding of three numbers using a function | |
// Define an add function | |
function add(a,b,c){ | |
return a + b + c; | |
} | |
// EXTRA ARGUMENT IS IGNORED | |
var e = add(1,2,3,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
console.log("Begin example - 4"); | |
// Adding of three numbers using a function | |
// Define an add function | |
function add(a,b,c){ | |
return a + b + c; | |
} | |
// Calling the function | |
var d = add(10,20,30); |
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
console.log("Begin example - 3"); | |
var p = 0; // Try replacing this with null, undefined, NaN | |
console.log("Value of p = " + p); | |
console.log("Boolean equivalent of p = " + Boolean(p)); // Truthy or Falsy value | |
// Example usage of truthy or falsy | |
if (p){ | |
console.log("I am happy"); | |
} else { | |
console.log("I am not sure"); | |
} |
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
// Variables declared by default are undefined | |
console.log("Begin example - 2"); | |
var x,y = 10; | |
console.log("Value of x = " + x); // X value is not defined, hence has undefiend | |
console.log("Value of y = " + y); | |
// Types demystified | |
console.log("Type of x = " + typeof(x)); // Type of undefined is undefined. | |
console.log("--"); |
NewerOlder