|
Double check how the project is set up then. Here's a fiddle of it...
JSFiddle[^]
Jeremy Falcon
|
|
|
|
|
I tried JSFiddle and it worked. However, when I copied the exact code to a new HTML page, it behaved the same way as it was without "Orange". Here is the complete HTML code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
<pre>
var fruit = 'Orange';
window.fruit = 'Apple';
function explainThis() {
alert(fruit + ' ' + this.fruit);
}
explainThis();
var stuff = new explainThis();
</script>
TOMZ_KV
|
|
|
|
|
Gotcha. It's because stuff ran on JSFiddle is a mock root and not the real root. When using the real root, as in your case, window is the default object, so in the real global scope the first two lines are pretty much the same since window is the default object and so the second assignment overwrites the first. In my original code, it was a fake root so to speak. I probably should've tested it first, but hey where's the fun in that.
To illustrate...
<!DOCTYPE html>
<html lang="en">
<head>
<script>
var fruitRoot = 'Banana';
window.fruitRoot = 'Pineapple';
function explainThisRoot() {
alert(fruitRoot + ' ' + this.fruitRoot);
}
explainThisRoot();
var stuffRoot = new explainThisRoot();
(function () {
var fruit = 'Orange';
window.fruit = 'Apple';
function explainThis() {
alert(fruit + ' ' + this.fruit);
}
explainThis();
var stuff = new explainThis();
})();
</script>
</head>
<body>
</body>
</html>
Jeremy Falcon
|
|
|
|
|
That explains it.
TOMZ_KV
|
|
|
|
|
What browser are you running out of curiosity?
Jeremy Falcon
|
|
|
|
|
Chrome 62.0.3202.94 and IE 11.726.15063.0
TOMZ_KV
|
|
|
|
|
And then the MORON who declares a variable like var window; which in one browser HIDES the window object, in the other it is ignored (a few years back).
And your code works in once place, and not the other! OMFG...
Otherwise, I actually LIKE javaScript as a teachable language. Just not the environment it lives!
|
|
|
|
|
Kirk 10389821 wrote: Otherwise, I actually LIKE javaScript as a teachable language. Just not the environment it lives!
I can see that. I would think that's my biggest qualm with it too, although I extend its environment to also mean the amount of people using it and everyone wanting to put their hand in the pie and make 40 million frameworks that aren't always designed well.
Jeremy Falcon
|
|
|
|
|
I never bother with bookmarks in the Chrome browser, because I organize my URL's of interest in a separate document.
But today, I wanted to bookmark the Jacquie Lawson Advent Calendar website my mother sent me. I realized I had absolutely no clue how to bookmark a page in Chrome. Had to google it. Oh, there's a "star" icon on the URL bar that I basically always ignore.
Now, how to find the bookmark. Ummm... Google again. Oh, the vertical ... and then "Bookmarks" But my bookmark isn't there. Another layer of indirection "Bookmark Manager" OK, still not there. Another layer of indirection (at this point I'm just clicking on things randomly) it's in the "Mobile bookmarks" folder.
WTF. I'm at home, on my laptop, not some mobile device. Gawd, these UI's suck trunk sometimes.
|
|
|
|
|
And why is there not a location bar drop down either?
|
|
|
|
|
there is a menu bar, on the menu bar is an item called Bookmarks. Oh wait, I'm using a good browser.
why do people use chrome?
apart from being a memory and CPU hog it's been so simplified (which makes that 'hog' thing even less rational) it needs a pack of add-ons to be remotely useful (which exacerbates the hog-ness). Perhaps the model they are using is soviet era cars? (Yes, those have a fan club too.)
In short: chrome sucks, it's not the fastest, it's far from the best.
(even ie has standard features chrome seriously needs).
Signature ready for installation. Please Reboot now.
|
|
|
|
|
Just more justification of my dislike of everything Google!
Get me coffee and no one gets hurt!
|
|
|
|
|
I hate how Chrome doesn't scroll tabs, instead making them smaller and smaller as more are opened. The designer that created that (and whoever approved it) need to be taken out and shot.
Chrome also OOMs my system within 10 minutes, and I have 24 GB RAM! It will OOM even if it is the only program I've opened.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
well firefox is a notorious memory leak, and IE is worse and slow, edge hides all the features... just sayin
Charlie Gilley
<italic>Stuck in a dysfunctional matrix from which I must escape...
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
I think you may find FF has drastically improved of late.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.
|
|
|
|
|
There's no money in giving people what they want -- you have to keep them wanting something better.
|
|
|
|
|
quoting marketing $$$t will get you banned from here. Seriously, I had a couple of multiple day meetings listening to stuff like this from the "sales guys" - I was the lone techie. I wanted to take the customer techies and kill my sales people.
|
|
|
|
|
Try CTRL+SHIFT+B - it toggles a bookmarks bar just under the URL/google bar.
When you click the star, it remembers the last set you used and adds it to that, but you can change that with the "Folder" dropdown that appears when you click the star.
It makes sense when you are used to it, but they do have an annoying habit of swapping the "done" and "remove" buttons.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: Try CTRL+SHIFT+B - it toggles a bookmarks bar just under the URL/google bar.
Quite so. I noticed the shortcut keys as I was traversing the menus. Then again, I'll probably forget them. Might already have.
|
|
|
|
|
Marc Clifton wrote: I'm at home, on my laptop, not some mobile device
I remember not so long ago laptops were being sold as being...mobile devices.
|
|
|
|
|
Thone who ask this question make an elementary mistake in assuming that "they" are capable of intelligent thought in the first place.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Ask your mum how to do it, I'm sure she knows it
You are a architect/programmer and searching too far
|
|
|
|
|
JustWatchLittle wrote: ou are a architect/programmer and searching too far
There's the problem! I need to be dumbed-down. Is there a google answer for that too?
|
|
|
|
|
I've got the Edge now, buggy at first but rapidly improving, I even read pdf's with it !
I'm using bookmarks a lot, but now I am at a point that I can't find anything because there are too many of them
|
|
|
|
|
Chrome is "special", even finding its version number was a challenge ... ,
BR
|
|
|
|