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
// Implement JSON.stringify | |
var example = { | |
"array": [1, 2, 3], | |
"number": 123, | |
"object": { | |
"a": "b", | |
"c": "d", | |
"e": "f" | |
}, | |
"string": "Hello World" |
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 words = [ | |
"wrt", | |
"wrf", | |
"er", | |
"ett", | |
"rftt" | |
] | |
var alphabet = [] | |
var hash = {}; |
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 runner = function(){ | |
return { | |
run: function(){ | |
console.log(this.name + ' is running away!'); | |
} | |
}; | |
}; | |
var swimmer = function(){ | |
return { |
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 barker = function(state){ | |
return { bark: function(){ console.log('Woof, I am ' + state.name); } }; | |
}; | |
var driver = function(state){ | |
return { drive: function(){ | |
state.position = state.position + state.speed; | |
console.log(state.position); | |
} }; | |
}; |
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 barker = (state) => ({ | |
bark: () => console.log('Woof, I am ' + state.name) | |
}) | |
const driver = (state) => ({ | |
drive: () => state.position = state.position + state.speed | |
}) | |
barker({ name: 'karo'}).bark() | |
// Woof, I am karo |
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 dog = () => { | |
const sound = 'woof' | |
return { | |
talk: () => console.log(sound) | |
} | |
} | |
const sniffles = dog() | |
sniffles.talk() // "woof" |
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 foo = { | |
a: function () { | |
console.log(this); | |
} | |
}; | |
foo.a(); | |
// => foo | |
foo['a'](); |
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 data = eval('(' + XMLHttpRequest.responseText + ')'); |
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 converter(st){ | |
var arrSt = st.split(''), | |
arrInt = []; | |
for (var i = 0; i < arrSt.length; i++){ | |
arrInt.push(arrSt[i].charCodeAt() - 48); | |
} | |
// loop over arry again |
NewerOlder