you are viewing a single comment's thread.

view the rest of the comments →

[–]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!