The code below is for context, but this concern is only regarding the HELP portion of the ïf conditional. The expected output is that the code within the if conditional will only run if the object &quot;newButton&quot; does not exist. I've tried typeof newButton === 'undefined', but it did not work. I've made sure that the type of newButton is in fact the string &quot;undefined&quot; before the if conditional, and I've included console.log() statements that show the type of the object newButton at two intervals. var alphabet = [&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;E&quot;, &quot;F&quot;, &quot;G&quot;, &quot;H&quot;, &quot;I&quot;, &quot;J&quot;, &quot;K&quot;, &quot;L&quot;, &quot;M&quot;, &quot;N&quot;, &quot;O&quot;, &quot;P&quot;, &quot;Q&quot;, &quot;R&quot;, &quot;S&quot;, &quot;T&quot;, &quot;U&quot;, &quot;V&quot;, &quot;W&quot;, &quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;]; var aI = 0;  //The &quot;rank&quot; input is given as a capital letter as a string (EX: &quot;A&quot;). function addNode(rank) {   var newNode = document.createElement(&quot;h1&quot;);   newNode.innerHTML = 0;   newNode.id = rank + alphabet[aI];   document.getElementById(&quot;nodeField&quot;).appendChild(newNode);    aI++;    console.log(typeof newButton); //Logs &quot;undefined&quot;    if (/*HELP*/ ) {     var newButton = document.createElement(&quot;button&quot;);     newButton.setAttribute(&quot;onclick&quot;, &quot;addNode('&quot; + alphabet[alphabet.indexOf(rank) + 1] + &quot;')&quot;);     newButton.innerHTML = &quot;Add Node to &quot; + alphabet[alphabet.indexOf(rank) + 1] + &quot; Rank&quot;;     document.getElementById(&quot;buttonField&quot;).appendChild(newButton);      console.log(typeof newButton); //Logs &quot;object&quot;   } }  Does anyone know how to fix this?
What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined globally?
exponentiation of cardinal number Any practical uses of machine learning for cryptography? How do I boot to a command line interface instead of a GUI? Hi I have ubuntu server 10.04 installed and I also installed the following:  su aptitude install xorg xfce4 aptitude install &lt;name of GUI browser, I use firefox&gt; aptitude install gedit aptitude install gnome-terminal   Now when I restart the system it goes to the GUI login, what I am really after is a system that loads the CLI by default and then I can use startx to load the GUI when really necessary. I am trying to learn CLI but I would like to retain access to the GUI for now. And, how can I switch between CLI and GUI anytime? What are turret connectors? While working on a project recently, I noticed that Digi-key has a product category . I've never seen connectors like this before, and they don't look like any kind of contact I've seen before. What does the mating connector look like? I can't envision any mating contact that makes any sense for these.  On top of that, they look like they have to be individually machined, which can't be a cost-effective process. Foolproof way to ensure Google news pulls the correct image for its thumbnails? Google news results have an acompanying thumbnail next to articles that show up in the results.    If Google's crawler can't find a thumbnail to pull from our site, it uses its next best guess from another site, therefore linking the image to another site but still uses our headline.  Example:  Headline from Reuters, Image from Livemint:   Our pages absolutely have images, they are not massive in file-size or dimensions, yet we are not having them pulled / crawled correctly.  We have read up on the suggestions from Google, and from others around the web and nothing is panning out.  Has anyone had any experience where they can ensure Google news will pull a thumbnail of our choosing? Show tabs in Chrome full screen mode? Firefox can do it, can Chrome?   Here's what I'm looking for: How to overlay images How do I create a permanent Bash alias? I would like to create an alias to rm command in order to have a confirmation message after executing this command. So I am creating an alias like this alias rm='rm -i'. But as far as I know this is a temporary alias and it lives until you close the terminal.  As it is explained  to save alias permanently I need to execute ~/.bash_aliases or ~/.bashrc commands in terminal and add my alias there. But when I execute ~/.bashrc I get following error message :  bash: /home/bakhtiyor/.bashrc: Permission denied   When I run ~/.bash_aliases I get another error message like this:  bash: /home/bakhtiyor/.bash_aliases: File or directory doesn't exist.   What is the actual problem and how can I solve it? Search and replace a line in a file in Python I want to loop over the contents of a text file and do a search and replace on some lines and write the result back to the file. I could first load the whole file in memory and then write it back, but that probably is not the best way to do it.  What is the best way to do this, within the following code?  f = open(file) for line in f:     if line.contains('foo'):         newline = line.replace('foo', 'bar')         # how to write this newline back to the file In Minecraft, I know you can breed animals. In fact, in recent updates it's required for the player who just can't start their mornings without bacon and eggs!  I've tried pulling two pigs together in a single pen, but all they do is snort at me. And the chickens? Well, there's plenty of eggs, but no hatching.  How do I get them to make more bacon and eggs? How to fix "error: unknown filesystem. grub rescue> I get this error:  Error: unknown filesystem. grub rescue&gt;   I'm not exactly sure what I did. I believe I installed Ubuntu over Windows on my Acer netbook. I then tried to install , but it wouldn't start installing.  I turned the netbook off and back on. Now I get the error.  I have read a lot of other questions like this, but in my case I cannot boot a CD. If I put a Ubuntu CD or a Linux Mint CD into my external CD/DVD drive and change my BIOS to boot the CD-ROM first, it just gives me the same error screen.  Update copied from comment dated 2012-05-26 02:54:29Z  Here are some results from my commands:   grub rescue&gt;ls (hd0) (hd0,msdos5) (hd0,msdos1)  grub rescue&gt;ls (hd0,msdos5) unknown filesystem  grub rescue&gt;ls (hd0,msdos1) unknown filesystem  grub rescue&gt;ls (hd0) unknown filesystem How can I convert a Unix timestamp to DateTime and vice versa? There is this example code, but then it starts talking about millisecond / nanosecond problems.  The same question is on MSDN, .  This is what I've got so far:  public Double CreatedEpoch {   get   {     DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();     TimeSpan span = (this.Created.ToLocalTime() - epoch);     return span.TotalSeconds;   }   set   {     DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime();     this.Created = epoch.AddSeconds(value);   } } High Voltage Powerlines - clarification of energy loss How to detect character sets encoding for all of language? What is the best method of re-rendering a web page on orientation change? How to reduce the size of VMware disk My Ubuntu image VMware disk has grown to 5GB physical file size. It's a dynamically growing disk with the maximum capacity of 8GB. I cleaned some stuff inside Linux distro and now inside it occupies 3GB. Obviously the physical file size didn't shrink back automatically. Is there a way (if possible free of charge) to shrink this disk back to ~3GB?  I need this to fit the image on the DVD. Make terminal use pageup/pagedown instead of shift-pageup/shift-pagedown? I've grown quite weary of shift-pgup to page up in gnome terminal, the command line, terminator, and guake, etc.  Any way to easily make these apps use the straight page-up and page-down keys for paging around? Last two digits of $2^{1000}$ via Chinese Remainder Theorem? I bumped across the aforementioned question in my notes while studying today and I have completely forgot how to do this. I remember using CRT to solve a problem like this on one of my tests, too bad they didn't give back my solutions :(.  Since $\gcd(100,2) = 2$, we can't use the usual Euler's theorem to solve via $\pmod {100}$. So $100 = 5^2 2^2$, and applying Euler's on the 25 gives me $2^{20} \equiv 1 \pmod {25}$. However since $\gcd(2,4) = 2$, we can't do the same for $\bmod 4$. Accordingly how do I set up the other modulo congruence so I can apply CRT? Can I use an "if" clause without "then"? How to change phone number in Google account? I gave Google my phone number to verify it, not knowing that it would change it, and now my phone number is completely different? What have I done, and how do I unverify it and change my phone number back?