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
// Define array | |
var products = ['apple', 'orange', 'banana']; | |
// Delete the product, but empty value remains in array | |
delete products[1]; | |
// Remove the empty value from the array | |
products = products.filter(function (el) { | |
return el != null; | |
}); |
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
<?php | |
// Method 1 | |
$json = file_get_contents('php://input'); | |
$json = mb_convert_encoding($json, 'UTF8', 'ASCII,JIS,UTF-8,EUC-JP,SJIS-WIN'); | |
$arr = json_decode($json,true); | |
echo "<pre>"; | |
print_r($arr); | |
echo "</pre>"; |
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 promiseFunction(url) { | |
return new Promise( function(resolve, reject){ | |
var xhr = new XMLHttpRequest(); | |
xhr.open("GET", url, true); | |
xhr.onload = function (e) { | |
if (xhr.readyState === 4) { | |
if (xhr.status === 200) { | |
resolve(xhr.responseText); | |
} else { | |
reject(xhr.statusText); |
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
var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming']; |
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
var provinces = [ | |
{ | |
'Name' : 'Ontario', | |
'Capital' : 'Toronto', | |
'Largest city' : 'Toronto' | |
}, | |
{ | |
'Name' : 'Quebec', | |
'Capital' : 'Quebec City', | |
'Largest city' : 'Montreal' |