Sunday, April 26, 2020
let's start with an official tip
Ternary Operator:
let isEmpty=true;
if(isEmpty==true){
console.log('Man this is empty');
} else {
console.log('not Empty');
}
which can be written as
isEmpty ? console.log('Man this is empty'): console.log('not empty');
For loop:
const lang=['c' , 'python' , 'javascript']
for (let i=0;i<lang.length;i++){
const lang = lang[i];
console.log(lang);
}
⇒
for(let lang of lang ) console.log(lang);
Assign value :
if (age){
age=age;
}else {
age=18;
}
⇒ let age= age || 18;
Template Literals:
const blog='art'
const sentence = 'blogging is an' + blog + '!' ;
⇒ const sentence = blogging is an ${blog}!;
Destructuring :
const post ={
data:{
blog_title:'6 killer tricks to write less Javascript',
author:'adarshreddy adelli',
};
}
const blog_title=post.data.blog_title;
const author=post.data.author;
⇒ const {blog_title , author } = post.data;
Identical keys and values :
const authorDetails ={
name : name,
email:email,
};
⇒ const authorDetails = { name , email};
Hope you liked this post. Thank you!
Sunday, April 26, 2020
javascript
0 Response to 6 killer tricks to write less Javascript
Comments are personally moderated by our team. Promotions are not encouraged.
Post a Comment