Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Sagiv ben giat sag1v

🎯
Focusing
  • AppsFlyer
  • israel
Block or report user

Report or block sag1v

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
Player.prototype.setScore = function(newScore){
this.score = newScore;
}
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
player1.setScore(1000);
player2.setScore(2000);
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
function createPlayer(userName, score) {
const newPlayer = {
userName,
score,
setScore(newScore) {
newPlayer.score = newScore;
}
}
return newPlayer;
}
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
function Player(userName, score) {
this.userName = userName;
this.score = score;
}
Player.prototype.setScore = function(newScore) {
this.score = newScore;
}
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
const player1 = Object.create(null)
player1.userName = 'sag1v';
player1['score'] = 700;
player1.setScore = function(newScore) {
player1.score = newScore;
}
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
Player.call(this, userName, score)
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
double.toString()
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
{
userName: 'sag1v',
score: 700,
setScore: ƒ
}
{
userName: 'sarah',
score: 900,
setScore: ƒ
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
function PaidPlayer(userName, score, balance) {
this.balance = balance;
/* we are calling "Player" without the "new" operator
but we use the "call" method,
which allows us to explicitly pass a ref for "this".
Now the "Player" function will mutate "this"
and will populate it with the relevant properties */
Player.call(this, userName, score);
}
@sag1v
sag1v / Markdium-JSX.jsx
Created Nov 25, 2019
Markdium-JavaScript - The prototype chain in depth
View Markdium-JSX.jsx
function double(num) {
return num * 2;
}
double.someProp = 'Hi there!';
double(5); // 10
double.someProp // Hi there!
double.prototype // {}
You can’t perform that action at this time.