2.Dəyişkənlərin təyini.
Uzun yol:
let vegetable;
let fruit= "apple";
Qısa yol:
let vegetable,fruit="apple";
3.Gizli Return
Uzun yol:
function calcCircle(diametr){
return Math.pi*diametr
}
Qısa yol:
calcCircle = diametr => Math.pi * diametr;
4. Çox sətirli string
Uzun yol:
const multiLine = " Multi \n\t"
+ "line \n\t"
+ "string \n\t"
Qısa yol:
const multiLine = `Multi
line
string`
5. Arrow functions
Uzun yol:
function hello(){
console.log("hello")}list.forEach(function(item){
console.log(item)
})
Qısa yol:
hello = () =>console.log("Hello");list.forEach(item => console.log("item"))
6. Template Literals
Uzun yol:
const welcome = “welcome ”+ fistname+ “ ” + lastname;const db = “http://”+host+ “:” + port+ “/” + database;
Qısa yol:
const welcome = `Welcome ${firstname} ${lastname}`;const db = `http://${host}:${port}/${database}`;