Variable and function names written as camelCase
Global/Constants variables written in UPPERCASE
$ in start of variable name used to hold JavaScript library objects
- variables:
| function selectToDatalist(theSelectElement) { | |
| // check if datalist supported first | |
| if ('options' in document.createElement('datalist')) { | |
| // get all options | |
| var options = theSelectElement.innerHTML; | |
| // Create the new datalist elements | |
| var theNewInputelement = document.createElement('input'); | |
| theNewInputelement.setAttribute('autocomplete', "off"); |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Document</title> | |
| <style> | |
| body { | |
| font-size: 16px; |
| function isValidDate(d) { | |
| return d instanceof Date && !IsNAN(d) | |
| } | |
| isValidDate(new Date("2020-30-30")) // false |
| public class ATM { | |
| public static void main(String[] args) { | |
| int[] DENOM = { 50, 100, 200 }; // bill types | |
| int[] bills = { 0, 0, 0 }; // how many bills have in ATM | |
| addBills(bills, new int[] { 2, 5, 6 }); | |
| System.out.println(cashBalance(DENOM, bills)); // 1800 | |
| System.out.println(); // true | |
| int amountToDispense = 1000; |
| import java.util.concurrent.ThreadLocalRandom; | |
| public class HelloWorld { | |
| public static void main(String []args){ | |
| int x = 13; | |
| int y = 5; | |
| // math operators | |
| int addition = x + y; // 18 |
| function OpenweathermapBuilder(key) { | |
| var queryStringParams; | |
| var baseApiUrl; | |
| baseApiUrl = 'http://api.openweathermap.org/data/2.5/weather'; | |
| queryStringParams = []; | |
| init(); | |
| function init() { |
| // const ENDPOINT = 'http://api.openweathermap.org/data/2.5/weather?q=jerusalem&units=metric&appid=1e8ffdb64b7d4d8dbdd4bf3a700bdeb0'; | |
| const ENDPOINT = 'weather.json'; | |
| fetch(ENDPOINT).then(res => res.json().then(weatherData => { | |
| console.log(weatherData); | |
| })) |
| const a1 = requireUncached('./mdl')('moshe') | |
| const a2 = requireUncached('./mdl')('moshe1') | |
| const a3 = requireUncached('./mdl')('moshe2') | |
| function requireUncached(module){ | |
| delete require.cache[require.resolve(module)] | |
| return require(module) | |
| } |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
| <title>Document</title> | |
| <script src="jquery.js"></script> | |
| </head> | |
| <body> |
Variable and function names written as camelCase
Global/Constants variables written in UPPERCASE
$ in start of variable name used to hold JavaScript library objects