|
|
|
|
|
by ywecur
3701 days ago
|
|
Your comment touches a lot on how to get an idea of the overall architecture, and I thank you for it. My main problem though is that I can't seem to see the purpose of functions, because more often than not they are written in a, to me, foreign way. An example I have is this uncommented if statement: `if (tab.url.toLowerCase().indexOf("https://facebook.com") > -1)` Should it be clear to me immediately that this means "If the target website is open"? It took me a solid minute just to understand this statement. Are there some common design patterns I should memorise? |
|
> if (tab.url.toLowerCase().indexOf("https://facebook.com") > -1)
> Should it be clear to me immediately that this means "If the target website is open"? It took me a solid minute just to understand this statement.
In theory you should figure out what the url-property of tab is (e.g. by logging it's value to the console). Then you see it is a string and check the javascript reference for toLowerCase() and indexOf().
When you've gained some experience you'll recognize those two functions immediately and know what they do and just assume that tab.url is a string (and you'll be mad at the original developer if it isn't).