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(){ | |
var a,b; | |
a=b = 3; | |
})(); | |
console.log("a defined? " + (typeof a !== 'undefined')); | |
console.log("b defined? " + (typeof b !== 'undefined')); |
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 foo() { | |
return { | |
bar: "hello" | |
}; | |
} | |
console.log(foo()) |
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 list = process.argv.slice(2); | |
var sum = 0; | |
var add = function () { | |
if (list.length === 0) { | |
console.log('sum ' + sum); | |
} | |
var item = list.pop(); |
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 args = process.argv.slice(2); | |
var hero = { | |
name: args[0], | |
getSecretIdentity: function (){ | |
return this.name; | |
} | |
}; | |
var stoleSecretIdentity = hero.getSecretIdentity.bind(hero); |
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 jsdom = require("jsdom"); | |
const { JSDOM } = jsdom; | |
const dom = new JSDOM(`<body></body>`, { runScripts: "dangerously" }); | |
function createDom(total) { | |
for (let i = 0; i < total; i++) { | |
var btn = dom.window.document.createElement('button'); | |
btn.appendChild(dom.window.document.createTextNode('Button ' + i)); | |
btn.addEventListener('click', function(){ console.log(i); }); |