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 localStorage = require('localStorage'); | |
localStorage.setItem('Apple', | |
`{ | |
"Products" : [ | |
{ "name": "iPhone"}, | |
{ "name": "iPad"}, | |
{ "name": "MacBook Pro"} | |
] | |
}`); |
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
'use strict'; | |
var rowHandler = ()=>{ | |
var table = document.getElementById("table1"); | |
var rows = table.getElementsByTagName("tr"); | |
for (i = 0; i < rows.length; i++) { | |
var curRow = table.rows[i]; | |
var onclikHandler = (row)=>{ | |
return ()=>{ | |
var cell = row.getElementsByTagName("td")[3]; | |
var color = cell.innerHTML; |
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 axios = require('axios'); | |
var url = "<THE LINK TO THE ENDPOINT OF API THAT HOSTS THE ABOVE DATA>"; | |
// the HTML markup that begins with headers, | |
//references to CSS and Javascript libraries, etc | |
var html = '<html><head>' | |
/* Add references here (I am using Bootstrap and jQuery)*/ | |
+'</head><body class="container">' | |
+'<div class="row">' | |
+'<table class="table">' |
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
class Product { | |
public string name { get; set; } | |
public string category { get; set; } | |
} | |
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
// Route: /[Controller name]/Apple | |
public ContentResult Apple() { | |
var response = getResponse(); // get the deserilized object(or a list of objects) | |
StringBuilder html = new StringBuilder("<html><head>" | |
+ " <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css\" >" | |
+ "</head><body class=\"container\">" |
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
private AppleInc getResponse() { | |
string json = ""; | |
/* Get HTTP response as JSON string (see explanation below)*/ | |
// Transform JSON into a C# object | |
var apple = JsonConvert.DeserializeObject<AppleInc>(json); |
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
<!-- Headers, etc above --> | |
<div class="row"> | |
<table class="table"> | |
<thead> | |
<tr> | |
<th>name</th> | |
<th>category</th> | |
</tr> | |
</thead> |
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 arr = []; | |
for (var i = 0; i<90000; i++){ | |
arr.push([i]); | |
} | |
var newArr =[]; |
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 startTime = new Date().getTime(); | |
newArr = arr.reduce((previous,current)=>{ | |
return previous.concat(current); | |
},[]); | |
console.log(new Date().getTime()-startTime); |
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 startTime = new Date().getTime(); | |
arr.forEach((e)=>{ | |
e.forEach((elem)=>{ | |
newArr.push(elem); | |
}); | |
}); | |
console.log(new Date().getTime()-startTime); |
OlderNewer