Wednesday, September 12, 2012

Coding with javascript and node.js

Easiest hello world ever:

console.log("Hello world!");

Super simple web page:

  <head><title>simple page</title></head>
    <h1 id="header">This is JavaScript</h1>
    <script type="text/javascript">
      document.body.appendChild(document.createTextNode('Hello World!'));
      var h1 = document.getElementById("header"); // holds a reference to the <h1> tag
      h1 = document.getElementsByTagName("h1")[0]; // accessing the same <h1> element
    <noscript>Your browser either does not support JavaScript, or has JavaScript turned off.</noscript>

Just save it in a file(call it "test.htm") and open the file; it pops up a browser window with a couple of messages. office application suite allows for JavaScript as one of its scripting languages.

Google Apps Script in Google Spreadsheets and Google Sites allows users to create custom formulas, automate repetitive tasks and also interact with other Google products such as Gmail.

Web applications within Firefox can be debugged using the Firebug add-on...Firefox also has a simpler built-in Error Console, which logs and evaluates JavaScript. It also logs CSS errors and warnings.

This page is good:

Node acts as the javascript interpreter and you run programs like this:

node testgrab.js

which runs the script testgrab.js.

No comments: