Skip to content

Instantly share code, notes, and snippets.

View leonardofed's full-sized avatar

@leonardofed leonardofed

View GitHub Profile
@getify
getify / 1.md
Last active January 17, 2020 16:35
A question about JS parameter scopes, and closures over them vs function scopes

I received a question about this snippet of code:

function def(first="oldValue" , second=function(){
         return first;
}){
        var first="updatedValue";
        console.log('inside',first);
        console.log('function',second());
}
EMAIL-GREP-PATTERN
<!-- Please remove all commented out code before using. Visit https://gist.github.com/ccstone/5385334 for more regular expressions available in TextWrangler -->
<!-- \r is line break, \s is non whitespace, \t tab, this looks for table cells and image tags with missing attributes -->
|<td>|<td>\r*?\s*?\t*?<img|(<img\s*(?!.*\r*?.*?\r*?.*?display: ?block.*?\r?))
<!-- image formatting and styles: height, width, block, alt text -->
|<img\s*(?!.*\r*?.*?\r*?.*?height.*?\r?)|<img\s*(?!.*\r*?.*?\r*?.*?width.*?\r?)
<!-- break tag variants -->
|<br/>|<br>
<!-- special characters -->