Skip to content

Instantly share code, notes, and snippets.

View rahulmalhotra's full-sized avatar
😃
Working on something amazing...!!

Rahul Malhotra rahulmalhotra

😃
Working on something amazing...!!
View GitHub Profile
@rahulmalhotra
rahulmalhotra / spreadoperator-part-2.js
Created January 21, 2021 11:03
This code snippet is used in ES6 Spread Operator JavaScript Tutorial by SFDC Stop
function eats(fruit1, fruit2, fruit3) {
console.log('Baby eats :- ', fruit1 + ', ' + fruit2 + ' and ' + fruit3);
}
let fruits = ['apple', 'mango', 'banana'];
eats(...fruits);
@rahulmalhotra
rahulmalhotra / spreadoperator-part-1.js
Created January 21, 2021 10:42
This code snippet is used in ES6 Spread Operator JavaScript Tutorial by SFDC Stop
// * 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 January 10, 2021 05:03
This code snippet is used in Default Parameters in ES6 JavaScript Tutorial for SFDC Stop
// * 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 January 10, 2021 04:55
This code snippet is used in Default Parameters in ES6 JavaScript Tutorial for SFDC Stop
// * Default value using ES6 syntax
function add(a, b = 2) {
console.log(a+b);
}
@rahulmalhotra
rahulmalhotra / function-default-parameters-es6-part-2.js
Created January 10, 2021 04:48
This code snippet is used in Default Parameters in ES6 JavaScript Tutorial for SFDC Stop
function add(a, b) {
b = b ? b : 2;
console.log(a+b);
}
@rahulmalhotra
rahulmalhotra / function-default-parameters-es6-part-1.js
Created January 10, 2021 04:41
This code snippet is used in Default Parameters in ES6 JavaScript Tutorial for SFDC Stop
function add(a, b) {
console.log(a+b);
}
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-5.js
Created January 9, 2021 14:14
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
let perimeterOfARectangle = (length, breadth) => 2 * (length + breadth);
console.log(perimeterOfARectangle(10, 20));
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-4.js
Created January 9, 2021 14:03
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
let perimeterOfACircle4 = radius => 2 * 3.14 * radius;
console.log(perimeterOfACircle4(10));
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-3.js
Created January 9, 2021 13:47
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
let perimeterOfACircle3 = (radius) => {
const PI = 3.14;
return 2 * PI * radius;
}
console.log(perimeterOfACircle3(10));
@rahulmalhotra
rahulmalhotra / fat-arrow-functions-part-2.js
Created January 9, 2021 13:05
This code snippet is used in Fat Arrow Functions in JavaScript Tutorial for SFDC Stop
let perimeterOfACircle2 = function(radius) {
const PI = 3.14;
return 2 * PI * radius;
}
console.log(perimeterOfACircle2(10));