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
// Here every then() method returns a new promise | |
// then() method always yields a promise after being executed, this way chaining is possible | |
// We can say here that every then() methods waits the previous promise to resolve | |
// Here the error handling is also easy. If any prior promise fails, catch() method will be triggered | |
fetch('https://api.openweathermap.org/data/2.5/weather?q=London,uk') | |
.then(response => { | |
return response.json(); | |
}) | |
.then(data => { | |
console.log(data); |
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
let baseNumber = 10; | |
addAnotherNumber(5); | |
baseNumber = 20; | |
// function closures have access to variable NAMES not the VALUES | |
// value is only checked when the function runs | |
function addAnotherNumber(num) { | |
setTimeout(function() { |
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
let result = 1; | |
// here this declaration must come first before using it | |
// it is a function variable declaration so it should be declared before its usage | |
const addNumber = function (numToAdd) { | |
result = result + numToAdd; | |
return result; | |
} | |
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 get_user_geo_country(){ | |
if(is_checkout()) { | |
$geo = new WC_Geolocation(); // Get WC_Geolocation instance object | |
$user_ip = $geo->get_ip_address(); // Get user IP | |
$user_geo = $geo->geolocate_ip( $user_ip ); // Get geolocated user data. | |
$country = $user_geo['country']; // Get the country code | |
if($country != 'DE') { | |
?> | |
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script> | |
<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
box-shadow: 3px 0 0 0 #000, | |
0 3px 0 0 #000, | |
3px 3px 0 0 #000, | |
3px 0 0 0 #000 inset, | |
0 3px 0 0 #000 inset; |
NewerOlder