E6 Javascript
If you use a larger dish than what is recommended
SELECT ct.ID, ct.Name, ord.Name, ord.Amount
FROM customers AS ct, orders AS ord
WHERE ct.ID=ord.Customer_ID
ORDER BY ct.ID;
<form onsubmit="return validate()" method="post">
Number: <input type="text" name="num1" id="num1" />
<br />
Repeat: <input type="text" name="num2" id="num2" />
<br />
<input type="submit" value="Submit" />
</form>
function validate() {
var n1 = document.getElementById("num1");
var n2 = document.getElementById("num2");
if(n1.value != "" && n2.value != "") {
if(n1.value == n2.value) {
return true;
}
}
alert("The values should be equal and not blank");
return false;
}
function add(x, y) {
var sum = x+y;
console.log(sum);
}
function add(x, y) {
var sum = x+y;
console.log(sum);
}
const add = (x, y) => {
let sum = x + y;
console.log(sum);
}
This new syntax is quite handy when you just need a simple function with one
argument.
You can skip typing function and return, as well as some parentheses and braces.
For example:
const greet = x => "Welcome " + x;
The code above defines a function named greet that has one argument and returns a
message.
If there are no parameters, an empty pair of parentheses should be used, as in
const x = () => alert("Hi");
The syntax is very useful for inline functions. For example, let's say we have an array,
and for each element of the array we need to execute a function. We use
the forEach method of the array to call a function for each element:
var arr = [2, 3, 7, 8];
arr.forEach(function(el) {
console.log(el * 2);
});
However, in ES6, the code above can be rewritten as following:
const arr = [2, 3, 7, 8];
arr.forEach(v => {
console.log(v * 2);
});