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 / classes-part-3.js
Created Feb 21, 2021
This code snippet is used in ES6 Classes JavaScript Tutorial on SFDC Stop
View classes-part-3.js
class Car {
#color
constructor(name, speed, color) {
this.name = name;
this.speed = speed;
this.#color = color;
}
@rahulmalhotra
rahulmalhotra / classes-part-2.js
Created Feb 17, 2021
This code snippet is used in ES6 Classes JavaScript Tutorial on SFDC Stop
View classes-part-2.js
class Car {
constructor(name, speed) {
this.name = name;
this.speed = speed;
}
showSpeed() {
console.log(this.speed);
}
@rahulmalhotra
rahulmalhotra / classes-part-1.js
Created Feb 17, 2021
This code snippet is used in ES6 Classes JavaScript Tutorial on SFDC Stop
View classes-part-1.js
function Car(name, speed) {
this.name = name;
this.speed = speed;
}
Car.prototype.showSpeed = function() {
console.log(this.speed);
}
let audi = new Car('audi', 200);
@rahulmalhotra
rahulmalhotra / spreadoperator-part-5.js
Created Jan 21, 2021
This code snippet is used in ES6 Spread Operator JavaScript Tutorial by SFDC Stop
View spreadoperator-part-5.js
let features = ['Great Speed', 'Good Color', 'Comfort', 'Good Looks'];
let moreFeatures = ['Great Mileage', 'Amazing Design', ...features];
console.log(moreFeatures);
@rahulmalhotra
rahulmalhotra / spreadoperator-part-4.js
Created Jan 21, 2021
This code snippet is used in ES6 Spread Operator JavaScript Tutorial by SFDC Stop
View spreadoperator-part-4.js
let features = ['Great Speed', 'Good Color', 'Comfort', 'Good Looks'];
let moreFeatures = ['Great Mileage', 'Amazing Design'];
features.push(...moreFeatures);
@rahulmalhotra
rahulmalhotra / spreadoperator-part-3.js
Created Jan 21, 2021
This code snippet is used in ES6 Spread Operator JavaScript Tutorial by SFDC Stop
View spreadoperator-part-3.js
// * Rest Parameters
function car(name, ...features) {
console.log('Features of Car ' + name + ' are:- ');
features.forEach(feature => {
console.log(feature);
});
}
car('Audi', 'Great Speed', 'Good Color', 'Comfort', 'Good Looks');
@rahulmalhotra
rahulmalhotra / spreadoperator-part-2.js
Created Jan 21, 2021
This code snippet is used in ES6 Spread Operator JavaScript Tutorial by SFDC Stop
View spreadoperator-part-2.js
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 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);
}