WebFund 2013F Lecture 5: Difference between revisions

From Soma-notes
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
Audio from the lecture given on September 23, 2013 is [http://homeostasis.scs.carleton.ca/~soma/webfund-2013f/lectures/comp2406-2013f-lec05-23Sep2013.m4a here].
==Readings==
==Readings==


Line 6: Line 8:


* node modules
* node modules
* function invocation patterns
** method
** function
** constructor
** apply
* function <tt>arguments</tt> array
* function <tt>arguments</tt> array
* return values
* return values
* <tt>try</tt>, <tt>catch</tt>, <tt>throw</tt>
 
==Notes==
 
September 23
 
var express = require('express')
  , routes = require('./routes');
* in the case of node, var express makes a local variable
** this means it is global (but private to) a file
** ./routes - a directory in the directory you are in
** express is somewhere else
*** express is in the node module directory
*** "look for the code in the express directories in one of the node modules"
* npm install populates the node modules directory
* exports object is a special object
exports.add = function(req, res){
    res.render('add', { title: 'Person added',
name: req.body.name,
country: req.body.country,
date: req.body.birthday,
email: req.body.email});
 
* come from text fields on page input from user
* res.render
** rendering in graphics -rendering a ball, wire frame, textures, lighting etc.
** this is what creates the page
** default renderer is jade
*** provides a template for entire page that is then filled in with parameters
h1 Info Added
p Name: #{name}
p Country: #{country}
p Date: #{date}
p Email: #{email}
* describes what your page will look like
* !!! is used in jade
** stuff needed for standard syntax
** doctype html
* jade-lang.com/reference
* html, jade, css, javascript
* html
** markup language with tags using angle brackets <> </>
* indentation in jade is very important
** kind of like python
** language for generating html pages
* div are divisions
** essentially specifying a block
* any time you call a function in javascript there is a thing called arguments
** it is bound to an area with all the arguments
** function takes a variable amount of arguments
* push
** in java script an array is already a stack
** can push an element on the top
** works for the first element in the array
* pop
** works for the last element of the array
* arrays are variably sized objects
** can be accessed in different throughout
** ordered
** similar to object
** loosely typed

Latest revision as of 21:38, 8 November 2013

Audio from the lecture given on September 23, 2013 is here.

Readings

  • Chapter 4 in Learning Node (Modules)

Topics

  • node modules
  • function arguments array
  • return values

Notes

September 23

var express = require('express')
  , routes = require('./routes');
  • in the case of node, var express makes a local variable
    • this means it is global (but private to) a file
    • ./routes - a directory in the directory you are in
    • express is somewhere else
      • express is in the node module directory
      • "look for the code in the express directories in one of the node modules"
  • npm install populates the node modules directory
  • exports object is a special object
exports.add = function(req, res){
    res.render('add', { title: 'Person added',
			name: req.body.name,
			country: req.body.country,
			date: req.body.birthday,
			email: req.body.email});
  • come from text fields on page input from user
  • res.render
    • rendering in graphics -rendering a ball, wire frame, textures, lighting etc.
    • this is what creates the page
    • default renderer is jade
      • provides a template for entire page that is then filled in with parameters
h1 Info Added
p Name: #{name}
p Country: #{country}
p Date: #{date}
p Email: #{email}
  • describes what your page will look like
  • !!! is used in jade
    • stuff needed for standard syntax
    • doctype html
  • jade-lang.com/reference
  • html, jade, css, javascript
  • html
    • markup language with tags using angle brackets <> </>
  • indentation in jade is very important
    • kind of like python
    • language for generating html pages
  • div are divisions
    • essentially specifying a block
  • any time you call a function in javascript there is a thing called arguments
    • it is bound to an area with all the arguments
    • function takes a variable amount of arguments
  • push
    • in java script an array is already a stack
    • can push an element on the top
    • works for the first element in the array
  • pop
    • works for the last element of the array
  • arrays are variably sized objects
    • can be accessed in different throughout
    • ordered
    • similar to object
    • loosely typed