ES6
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
let qs = "?q=javascript&num=10"; | |
let searchParams = new URLSearchParams(qs); | |
console.log(searchParams.toString()); // " q=javascript&num=10" | |
searchParams.has("num"); // true | |
searchParams.get("num"); // 10 | |
searchParams.set("page", "3"); | |
console.log(searchParams.toString()); // " q=javascript&num=10&page=3" | |
searchParams.delete("q"); | |
console.log(searchParams.toString()); |
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
/** | |
* TOC.js: create a table of contents for a document. | |
* | |
* This module registers an anonymous function that runs automatically | |
* when the document finishes loading. When it runs, the function first | |
* looks for a document element with an id of "TOC". If there is no | |
* such element it creates one at the start of the document. | |
* | |
* Next, the function finds all <h1> through <h6> tags, treats them as | |
* section titles, and creates a table of contents within the TOC |
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
<? | |
include_once("libs/smarty.class.php"); | |
$smarty = new smarty(); | |
$students = array( | |
"didar" => array("name"=>"Didar Bhuiyan","roll"=>12), | |
"emran" => array("name"=>"Emran Hasan","roll"=>18), | |
"hasan" => array("name"=>"Tanveer Hasan","roll"=>23)); | |
$smarty->assign("students",$students); | |
$smarty->display("associative_array.tpl"); | |
?> |
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
function getImgAreas( ) { | |
var result; | |
// make sure browser supports img element objects | |
if (document.images) { | |
// initialize return value so we can add to it | |
result = 0; | |
// loop through all img objects on the page | |
for (var i = 0; i < document.images.length; i++) { | |
// accumulate image areas | |
result += (document.images[i].width * document.images[i].height); |
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
function object2String(obj) { | |
var val, output = ""; | |
if (obj) { | |
output += "{"; | |
for (var i in obj) { | |
val = obj[i]; | |
switch (typeof val) { | |
case ("object"): | |
if (val[0]) { | |
output += i + ":" + array2String(val) + ","; |