Skip to content

Instantly share code, notes, and snippets.

View rehasantiago's full-sized avatar
🏠
Working from home

Reha Santiago rehasantiago

🏠
Working from home
  • Yellow Messenger
  • Mumbai, India
View GitHub Profile
@rehasantiago
rehasantiago / cantSolve1.js
Created August 6, 2022 15:16
I bet you can't solve these 1
function foo() {
let a = b = 0;
a++;
return a;
}
foo();
console.log(typeof a);
console.log(typeof b);
<script>
// Debouncing in Javascript
let counter = 0;
const getData = () => {
// calls an API and gets Data
console.log("Fetching Data ..", counter++);
}
const debounce = function (fn, d) {
let timer;
let song1 = {
song: 'Blank Space',
getSong: function() {
console.log(this.song);
}
};
let song2 = {
song: 'Levitating',
};
let song3 = {
let song1 = {
song: 'Blank Space',
getSong: function() {
console.log(this.song);
}
};
let song2 = {
song: 'Shape of you',
};
let song = {
songName: 'Blank Space',
getSong: function() {
console.log(this.songName);
}
};
let song1 = song.getSong.bind(song); // Blank Space
setTimeout(song1, 1000);
let song = {
songName: 'Blank Space',
getSong: function() {
console.log(this.songName);
}
}
let song1 = song.getSong;
setTimeout(song1, 1000);// undefined
let song = {
songName: 'Blank Space',
getSong: function() {
console.log(this.songName);
}
}
setTimeout(song.getSong, 1000)// undefined
function singerName() {
console.log(this.name);
}
let singer1 = {name: 'Taylor Swift'};
let taylor = singerName.bind(singer1);
taylor(); // Taylor Swift
var singer = {
name: "Dua Lipa",
songs: function() {
function songAndSinger(){
console.log(this === singer) // true
}
songAndSinger.apply(singer)
}
}
singer.songs();
var singer = {
name: "Dua Lipa",
songs: function() {
function songAndSinger() {
console.log(this === singer) // true
}
songAndSinger.call(singer);
}
}
singer.songs();