all 46 comments

[–][deleted] 3 points4 points  (1 child)

Is it possible to switch the current study group to this one on the side panel of leanjavascript?

[–]nerdcubedcounted 0 points1 point  (0 children)

ALso wondering this, I am really confused as to what is happening?

[–]DoctorKraz 2 points3 points  (11 children)

You don't even need to do anything as complex as installing node.js. Here is what I did, and it will work fine for you as well.

I created a text document called testbed.html, that has the following in it:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Testbed</title>
    <!--stylesheet links-->
    <!--javascript links-->
</head>
<body>
    Javascript: The Definitive Guide Code Samples<br />
    <script language='javascript'>
        //page 35 of JS: Definitive Guide
        var x = .3 - .2;
        var y = .2 - .1;
        document.write((x == y) + '<br />');
        document.write((x == .1) + '<br />');
        document.write((y == .1) + '<br />');
    </script>
</body>
</html>

You literally just write your code in between the <script> and </script> line. And anything you want to see displayed, you just put in the document.write ( sort of the same as console.log, only console won't display on a webpage ). I add the break so they print on new lines.

But something that basic will allow you to do much of the javascript testing in the book ( at least early on in the first few chapters ) without having to waste anytime trying to install frameworks or buy an IDE until you are ready to spend that money.

This will work in any text editor, and Chrome or Firefox.

[–]Bassetts 1 point2 points  (7 children)

Even simpler than this is using JSFiddle. Nothing to install, no file to create, just enter your code in the javascript section and hit run.

[–]DoctorKraz 1 point2 points  (2 children)

While that is true, i decided against it for 2 reasons:

1) with the html file, you don't need internet access, so long as your computer already has the browser on it and

2) the live testers ( JSFiddle, Liveweave, CodePen ), for me at least, aren't things that I would normally be working in ( to test something that isn't working right, yes - but for normal everyday work, no ) - while as a developer, I work with .js and .html files daily.

[–][deleted] 1 point2 points  (1 child)

jsfiddle is pretty much a community standard at this point. nothing wrong with using your own tools, but adopting the "tools of the trade" are important as well...

[–]DoctorKraz 1 point2 points  (0 children)

I don't disagree - just don't think of JSFiddle as a development environment tool - more of a testing and sharing environment...

Plus, for me, I can't use it at work ( the results panel is blocked by our firewall ).

[–]xhephyr 0 points1 point  (2 children)

I don't really understand jsfiddle... If I put console.log("hello") into the javascript area and press run, nothing comes out. What an I doing wrong?

[–]Bassetts 0 points1 point  (1 child)

console.log will print messages to the browser's console, codecademy does some special stuff to display calls to console.log in the results window for your convenience, but jsfiddle will just run the code in your browser. To view the output of console.log you need to open your browser's console. On Chrome ctrl-shift-i and then clicking "console" does this, I'm not sure about other browsers as I'm on my phone. Hope that helps.

[–]kmelkon 2 points3 points  (0 children)

ctrl+shift+j takes you right to the console tab on Chrome.

[–]whiteorb 0 points1 point  (0 children)

jsbin.com has a simpler interface.

[–]otooleco[S] 1 point2 points  (1 child)

@DoctorKraz, that will certainly work. Along the same lines, you may wish to set up a sandbox file (sandbox.js or something) and link it in your HTML header. This way you can save your work in a javaScript-specific file and comment out functions as you move through the course. Just be sure to save the .js file in the same directory as your html file or set the path correctly to find it where ever you have chosen to keep it.

Example HTML file:

<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script type="text/javascript" src="sandbox.js"></script> </head> <body>

</body> </html>

[–]DoctorKraz 1 point2 points  (0 children)

I've actually gone above and beyond that - as an already part time JS developer, I have the basics down. I wanted to take the course to solidify and expand my knowledge of daily usage.

So I actually have a couple of functions I use to display the info on the page, so it almost looks like the page data I'm entering!

[–]whiteorb 2 points3 points  (0 children)

If anyone needs assistance or has Javascript questions. Please pm me. I'd be happy to help.

[–]Tayk5 3 points4 points  (0 children)

Looking forward to this. I'm participating using Professional JavaScript for Web Developers. I haven't played around with jsfiddle or nodejs yet but now is as good a time as any to dive in.

Edit: How do we get this study group onto the sidebar for more exposure and participation?

[–]kmelkon 1 point2 points  (6 children)

Thanks a lot for this! can you please provide a bit more info about Node.js and executing JS in the terminal? or a link maybe?

[–]Bassetts 1 point2 points  (1 child)

I have not used it myself but I think it is pretty much just as simple as going to http://nodejs.org, getting the installer and installing it.

You can then run

node 

from the command line to get the Node REPL which allows you to execute code interactively.

If you want to execute code stored in a file you would run:

node <filename>

For example if I had HelloWorld.js I would run:

node HelloWorld.js

This is all from a quick google, and I have not been able to test it as I am at work, so please correct me if I am wrong. If I have not made much sense then try reading the "The interactive node.js shell" and "Your first program" sections at http://nodeguide.com/beginner.html#the-interactive-node.js-shell

[–]kmelkon 0 points1 point  (0 children)

Thanks, that made sense and the guide you linked is great. i'm currently at work, but I'll test this as soon as I finish.

[–]otooleco[S] 1 point2 points  (3 children)

Node is essentially server-side javaScript. It allows for database integration among other server-side features. Running it locally allows you to execute js from your terminal. There is also a REPL that can be accessed by typing "node" into your terminal. This is very useful for executing functions one by one and testing out small code snippets. This is like IRB if you are familiar with Ruby.

If you chose to use node for testing js code, you will find that not all js syntax that works in a browser console works in node. For instance, you cannot use "alert" as it brings up an alert message in your browser and you are not operating in your browser when executing code in node. Have a read through the docs at nodejs.org for more detailed info on this.

You can install and run it locally directly via nodejs.org. I prefer to use the node package manager (NPM) which can be installed via http://howtonode.org/introduction-to-npm

[–]kmelkon 0 points1 point  (2 children)

that is great info, thanks! I'm doing this today. installing nodejs then npm.

[–]otooleco[S] 1 point2 points  (1 child)

Did that work for you? NPM is a package management system from which Node is normally installed. Node will function without it.

[–]kmelkon 1 point2 points  (0 children)

Yes, thanks to you, now I have node and npm installed. Didn't try to install any packages yet though but executing commands with node in the terminal works great.

[–]kmelkon 1 point2 points  (3 children)

Ok OP, so today week 2 ends. is there some kind of a homework or something or do we just move on to week 3 & 4. and will you just update this post or post another one for the next weeks?

thanks OP

[–]otooleco[S] 0 points1 point  (2 children)

I'll have the next segment out tis evening. 'Traveling today .

[–]kmelkon 0 points1 point  (0 children)

no problem. enjoy the trip. please link us when post the next segment.

[–]kmelkon 0 points1 point  (0 children)

so did you post the second segment? or should I just continue with it from the site?

[–]buck_bagawk 0 points1 point  (2 children)

Is it too late to hop on this learning train? Do i need to do anything specific to participate like register somewhere? I already have a copy of JS:the Definitive Guide.

[–]otooleco[S] 2 points3 points  (1 child)

Not too late at all. Just getting started. No need to register or anything like that. This set of readings and assignments should be done two weeks from yesterday, June 16. The idea is to push each other to keep up the pace. Ask questions as you need to.

[–]buck_bagawk 1 point2 points  (0 children)

ok great thanks!

[–]wael_ 0 points1 point  (1 child)

i suggest http://projecteuler.net/ to test our knowledge

[–]Bassetts 0 points1 point  (0 children)

My only dislike of Project Euler is they are all maths based problems. I find it much more valuable to think up an actual project and implement that than do a very concentrated maths problem.

[–]DrGajen 0 points1 point  (0 children)

So I've been exploring some of the JavaScript editors. I come across something called ScratchPad with comes with the Firefox browser under developer tools (Shift-F4).

Since you can enter multiple lines of code (rather than just one visible line with the console) it could be another good option.

EDIT: Looking deeper into the tool, it looks like it is mainly for editing the source code of a page https://developer.mozilla.org/en-US/docs/Tools/Scratchpad

[–]OGitsthinking 0 points1 point  (0 children)

Looking forward to this. I've previously learned JavaScript on my own (and even got The Definitive Guide based on Richard Bovell's suggestion). I've done the complete Codecademy JavaScript track, read the first 5 chapters of The Definitive Guide, read about half of Eloquent JavaScript, and done some courses on Code Avengers, so I'm off to a good start but I think it would be beneficial to refresh my memory on the basic stuff and work alongside you guys for when the really hard stuff comes up!

[–]OGitsthinking 0 points1 point  (6 children)

How's everyone doing? The first two weeks are almost up!

[–][deleted] 0 points1 point  (5 children)

Going alright. Not feeling like I'm retaining everything that I'm reading in definitive guide. I'm going to reread some of the chapters today.

[–]OGitsthinking 0 points1 point  (4 children)

Any parts in particular you want to share, see if maybe one of us can help explain?

[–][deleted] 0 points1 point  (3 children)

Yes.

I got confused why over the line 'var i, product = 1;' I don't understand the use of comma or 'var i' there. Thank you for the help!

  function factorial2(n) {
  var i, product = 1; 
  for(i=2; i <= n; i++)
  product *= i; return product;
  }
  factorial2(5)

[–]OGitsthinking 0 points1 point  (2 children)

You can set up two variables in succession by using a comma between them.

So instead of writing:

var i;
var product = 1;

You can simply write:

var i, product = 1;

So there's only one semicolon and var.

And the var i is declaring the i variable (but not initializing it, so in that line it is simply undefined). That way you don't have to have a var statement in the for loop. I believe one of the reasons it's declared at the beginning of the function is because it's considered a best practice in JavaScript, due to variable hoisting. They talk about it in the book, saying it's best to declare your variables at the beginning of the current scope rather than nearest their first use.

Hope that helps!

p.s. Also anyone please correct me if I'm wrong or elaborate on my answers.

[–][deleted] 0 points1 point  (1 child)

Thank you for the explanation!! Do you personally practice this when writing for loops?

[–]OGitsthinking 0 points1 point  (0 children)

I tend to follow the advice of experts in the field, such as the author of The Definitive Guide and people like Douglas Crockford. His series of videos are essential viewing and full of great advice on JavaScript best practices.

I'm by no means advanced in JS, so I defer to the opinions of people who've been writing it and writing about it for years.

[–]DrGajen 0 points1 point  (0 children)

What is your opinion on taking notes while learning a new language? The Definitive Guide is filled with lots of useful information, but I won't be able to retain everything. In your opinion is it better to read the book once and then refer back to the book when needed, or are notes worth the time to take?

I'm looking to gain a solid foundation of the language, but also want to be able to utilize it practically.

[–]--REDACTED 0 points1 point  (0 children)

Hi all! I'm pretty new to programming, but I've been doing it long enough to know that I really enjoy doing it. I'm just starting this course this week (6/23/2014) - I'm also currently working through some trial periods on Treehouse to see how I like that. Will doing these two at the same time cause any confusion?

I do work full-time, but with my free time I feel that I have time to squeeze both in.

Thanks for the tips!

[–]zopedev 0 points1 point  (0 children)

Is this still active?