Skip to content

Instantly share code, notes, and snippets.

View rrameshbtech's full-sized avatar

Ramesh Ramalingam rrameshbtech

  • ThoughtWorks
  • Coimbatore, India
  • 01:09 (UTC +05:30)
View GitHub Profile
<div class="card_block">
<div class="card_block_body form_body">
<div id="carePlan">
<div
class="panel-group"
id="accordion"
role="tablist"
aria-multiselectable="true"
>
<div class="card panel-default">

Keybase proof

I hereby claim:

  • I am rrameshbtech on github.
  • I am rrameshbtech (https://keybase.io/rrameshbtech) on keybase.
  • I have a public key ASDPV0zpkPl2tktzxFR6-4fuDg9TClVeIY3HEUOEB4AtKAo

To claim this, I am signing this object:

@rrameshbtech
rrameshbtech / explicit-binding-this.js
Last active November 17, 2018 02:13
Explicit binding of this using call & apply
const siliconVallyOfIndia = {
city: 'Bengaluru',
speciality: 'software industries'
};
const texCity = {
city: 'Tiruppur',
speciality: 'textile industries'
};
const City = function (cityName, knownFor) {
this.name = cityName;
this.speciality = knownFor;
this.print = function () {
console.log(`${this.name} is know for ${this.speciality}`);
};
};
const karur = new City('Karur', 'Textiles');
<html>
<button id="thisButton" onclick="verifyThis(this)">Check this</button>
<script>
const thisButton = document.getElementById('thisButton');
function verifyThis(buttonWhichTriggered) {
console.log(buttonWhichTriggered === thisButton); // true
console.log(this === window); // true
}
</script>
<html>
<button id="thisButton">Check this</button>
<script>
const thisButton = document.getElementById('thisButton');
thisButton.addEventListener('click', verifyThis);
function verifyThis(event) {
//this is bound to the button onwhich the click event is triggered
console.log(this === thisButton); // true
console.log(this === event.currentTarget); // true
function printSpeciality() {
console.log(`${this.city} is know for ${this.speciality}`);
}
const printKarurSpeciality = printSpeciality.bind({city: 'Karur', speciality: 'Textile Industries'});
printKarurSpeciality(); // Karur is know for Textile Industries
const printCoimbatoreSpeciality = printSpeciality.bind({city: 'Coimbatore', speciality: 'Mechanical Industries'});
printCoimbatoreSpeciality(); // Coimbatore is know for Mechanical Industries
@rrameshbtech
rrameshbtech / explicit-binding-this.js
Last active July 30, 2018 09:21
Explicit binding of this using call & apply
const siliconVallyOfIndia = {
city: 'Bengaluru',
speciality: 'software industries'
};
const texCity = {
city: 'Tiruppur',
speciality: 'textile industries'
};
let manchesterOfSouthIndia = {
city: 'Coimbatore',
speciality: 'mechanical industries',
}
manchesterOfSouthIndia.getSpeciality = function() {
return this.city + ' is known for ' + this.speciality;
}
console.log(manchesterOfSouthIndia.getSpeciality()); // Coimbatore is known for mechanical industries
let manchesterOfSouthIndia = {
city: 'Coimbatore',
speciality: 'cotton industries',
getSpeciality: function() {
return this.city + ' is known for ' + this.speciality;
}
}
console.log(manchesterOfSouthIndia.getSpeciality()); // Coimbatore is known for cotton industries