Tagged Questions
4
votes
1answer
50 views
Elegant memoizing
I wanted an elegant way to implement memoizing. Here is what I came up with:
function memoize(fn) {
var cache = new WeakMap();
return function() {
if (!cache[arguments]) {
...
1
vote
3answers
89 views
Caching a JS selector then only using it once
I have this code:
var submit = document.getElementById('submit');
var error = document.getElementById('error');
var url;
submit.onclick = function(){
url = document.getElementById('url').value;
...