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
const age = 2; | |
function example(str) { | |
eval(str); | |
console.log(age); | |
} | |
example('const age=3;'); //output:2 | |
example("'use strict'; var age=6;"); //output:2 | |
example('var age=4;'); // output: 4 |
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
const obj = { | |
a: 1, | |
b: 2, | |
c: 3, | |
}; | |
with (obj) { | |
d = 4; | |
} | |
console.log(obj) // output: {a: 1, b: 2, c: 3} |
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
const obj = { | |
a: 1, | |
b: 2, | |
c: 3, | |
}; | |
with (obj) { | |
a = 3; | |
b = 4; | |
c = 5; |
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
function Person(name, age) { | |
this.name = name; | |
this.age = age; | |
this.getName = function() { | |
return this.name; | |
} | |
} | |
Person.prototype.getAge = function() { | |
return this.age; |
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
var age = 2; | |
const person = { | |
age: 1, | |
doSomething(name) { | |
console.log(this === person); | |
console.log(this.age); | |
console.log(name); | |
}, | |
}; | |
const extractFn = person.doSomething; |
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
var age = 2; | |
const person = { | |
age: 1, | |
doSomething() { | |
console.log(this === person); // output: true | |
console.log(this.age); // output: 1 | |
}, | |
}; | |
person.doSomething(); |
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
function str2ab(str) { | |
const buf = new ArrayBuffer(str.length*2); // 2 bytes for each char | |
const bufView = new Uint16Array(buf); | |
for (let i=0, strLen=str.length; i < strLen; i++) { | |
bufView[i] = str.charCodeAt(i); | |
} | |
return buf; | |
} | |
function ab2str(buf) { | |
return String.fromCharCode.apply(null, new Uint8Array(buf)); |
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
html, body { | |
height: 100%; | |
margin: 0; | |
} | |
.app { | |
height: 100%; | |
display: grid; | |
grid-template-rows: 45px 1fr; | |
grid-template-columns: 200px 1fr; |