/    Sign up×
Community /Pin to ProfileBookmark

abouthome.js mozilla start page explanation

Hello,
Ia am trying to understand by myself some random pages on the net, and I have started with the default firefox 11 start page, which is entirely stored with the installation.
And I have several things I cannot understand at all, especially in the javascript part. I am sorry if my questions will look stupid for you, I am starting to deal with real life programs only now. And they always give me the impression that “yes, you know, this is because they use this extension of the language, which allows this, etc”.

For example, here is the beginning of a function:

[code=php]function setupSearchEngine()
{
gSearchEngine = JSON.parse(localStorage[“search-engine”]);[/code]

what on hell is “localStorage”? some “tacitly know” table? And especially, why is this “localStorage” not defined anywhere in the “abouthome.js” file? I would understand if there was some library associations at the beginning of the file, but hell no, there is NOTHING in the beginning of the file! You just have to understand, all by yourself, what “localStorage” means, and how comes it is understood by the javascript interpreter as something properly defined, in the PRECISE context…of the firefox start page. How on earth could I find documentation on that, even the mozilla developper network does not feature a link to “explaining the code of existing application parts”… and I would need to repeat that procedure of impossible search for every similar problem I find!

I am asking, how do you, folks, learn web developing when you have absolutely NO friend that knows something in coding, no class lessons about that, and completely specific and obscure things like this that deny all the laws of programming you have ever learned at school??

i know, there must be some dumb reason, as always. I am just too stupid to find it…

here another example:

[code=php]let gSearchEngine;[/code]

and then, without warning:

[code=php]let url = gSearchEngine.searchUrl;[/code]

how then does Javascript knows that when it created the gsearchengine object, it was an object of a type that had a “searchurl” field…I am lost there.

Can someone help me and explain why this piece (abouthome.js) of code seems to know things it should not know?

I know these difficulties are probably temporary, and are due to me having to cross the entrance barrier to javascript. Once I will know more, it will become easier to guess things…

Thanks for your help, and sorry for the long message from a beginner!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @MrBrody spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...