This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj1 = { | |
innerMethod: function () { | |
console.log(this); | |
} | |
}; | |
let func1 = obj1.innerMethod; | |
func1(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj1 = { | |
innerMethod: function () { | |
innerFunction(); | |
function innerFunction() { | |
console.log(this); | |
} | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj1 = { | |
innerMethod: function () { | |
let self = this; | |
innerFunction(); | |
function innerFunction() { | |
console.log(self); | |
} | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj1 = {}; | |
function func1() { | |
console.log(this); | |
} | |
func1(); | |
func1.bind(obj1)(); // bind returns a function | |
func1.call(obj1); | |
func1.apply(obj1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
let func1 = () => { | |
console.log(this); | |
}; | |
func1(); | |
// Window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj1 = { | |
innerMethod: () => { | |
console.log(this); | |
} | |
}; | |
obj1.innerMethod(); | |
// Window |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj1 = { | |
innerFunction: null, | |
innerMethod: function () { | |
this.innerFunction = () => { console.log(this) }; | |
} | |
}; | |
obj1.innerMethod(); | |
obj1.innerFunction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let obj1 = {}; | |
let func1 = () => { | |
console.log(this); | |
} | |
func1(); | |
func1.bind(obj1)(); // bind returns a function | |
func1.call(obj1); | |
func1.apply(obj1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS blogs ( | |
id int(11) NOT NULL AUTO_INCREMENT, | |
title varchar(255) NOT NULL, | |
content text NOT NULL, | |
slug varchar(255) NOT NULL UNIQUE, | |
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
PRIMARY KEY (id) | |
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE IF NOT EXISTS users ( | |
id int(11) NOT NULL AUTO_INCREMENT, | |
name varchar(255) NOT NULL, | |
email varchar(255) NOT NULL UNIQUE, | |
password varchar(255) NOT NULL, | |
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
PRIMARY KEY (id) | |
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; |