Skip to content

Instantly share code, notes, and snippets.

Avatar
😃
Working on something amazing...!!

Rahul Malhotra rahulmalhotra

😃
Working on something amazing...!!
View GitHub Profile
@rahulmalhotra
rahulmalhotra / spreadoperator-part-1.js
Created Jan 21, 2021
This code snippet is used in ES6 Spread Operator JavaScript Tutorial by SFDC Stop
View spreadoperator-part-1.js
// * Spread Operator in JavaScript ES6
function eats(fruit1, fruit2, fruit3) {
console.log('Baby eats :- ', fruit1 + ', ' + fruit2 + ' and ' + fruit3);
}
let fruits = ['apple', 'mango', 'banana'];
eats(fruits[0], fruits[1], fruits[2]);
@rahulmalhotra
rahulmalhotra / function-default-parameters-es6-part-4.js
Created Jan 10, 2021
This code snippet is used in Default Parameters in ES6 JavaScript Tutorial for SFDC Stop
View function-default-parameters-es6-part-4.js
// * Default value to an object being passed as a parameter using ES6 syntax
function personAge(age, { firstName = 'Richard', lastName = 'Hendricks' } = {}) {
console.log(firstName + ' ' + lastName + ' is ' + age + ' years old');
}
@rahulmalhotra
rahulmalhotra / function-default-parameters-es6-part-3.js
Created Jan 10, 2021
This code snippet is used in Default Parameters in ES6 JavaScript Tutorial for SFDC Stop
View function-default-parameters-es6-part-3.js
// * Default value using ES6 syntax
function add(a, b = 2) {
console.log(a+b);
}
@rahulmalhotra
rahulmalhotra / function-default-parameters-es6-part-2.js
Created Jan 10, 2021
This code snippet is used in Default Parameters in ES6 JavaScript Tutorial for SFDC Stop
View function-default-parameters-es6-part-2.js
function add(a, b) {
b = b ? b : 2;
console.log(a+b);
}
@rahulmalhotra
rahulmalhotra / function-default-parameters-es6-part-1.js
Created Jan 10, 2021
This code snippet is used in Default Parameters in ES6 JavaScript Tutorial for SFDC Stop
View function-default-parameters-es6-part-1.js
function add(a, b) {
console.log(a+b);
}
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-5.js
Created Jan 9, 2021
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
View fat-arrow-functions-part-5.js
let perimeterOfARectangle = (length, breadth) => 2 * (length + breadth);
console.log(perimeterOfARectangle(10, 20));
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-4.js
Created Jan 9, 2021
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
View fat-arrow-functions-part-4.js
let perimeterOfACircle4 = radius => 2 * 3.14 * radius;
console.log(perimeterOfACircle4(10));
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-3.js
Created Jan 9, 2021
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
View fat-arrow-functions-part-3.js
let perimeterOfACircle3 = (radius) => {
const PI = 3.14;
return 2 * PI * radius;
}
console.log(perimeterOfACircle3(10));
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-2.js
Created Jan 9, 2021
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
View fat-arrow-functions-part-2.js
let perimeterOfACircle2 = function(radius) {
const PI = 3.14;
return 2 * PI * radius;
}
console.log(perimeterOfACircle2(10));
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-1.js
Created Jan 9, 2021
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
View fat-arrow-functions-part-1.js
function perimeterOfACircle1(radius) {
const PI = 3.14;
return 2 * PI * radius;
}
console.log(perimeterOfACircle1(10));