Notes on some Computer Technologies



HARDWARE

x86

__

System bus

__

RAM

__

Data storage devices

__



SOFTWARE

Unix

Unix shell Bash

1989, Brian Fox

Bash Reference Manual
maintainer's Bash page incl FAQ
BASH programming introduction
Type bash --version at the Bash command line to determine what version you are in.

Text Editors

namehow to quit
edq <enter>
emacs^x^c
nano^x
vi:q <enter>

Character Encoding

ASCII

8-bit codes, mapped to 256 different characters
American Standard Code for Information Interchange

Variable-Width Encoding

usually the result of a need to increase the number of characters which can be encoded without breaking backward compatibility with an existing constraint. For example, with one byte (8 bits) per character, one can encode 256 possible characters; in order to encode more than 256 characters, the obvious choice would be to use two or more bytes per encoding unit, ... but such a change would break compatibility with existing systems and therefore might not be feasible at all.

Since the aim of a multibyte encoding system is to minimize changes to existing application software, some characters must retain their pre-existing single-unit codes, even while other characters have multiple units in their codes. The result is that there are three sorts of units in a variable-width encoding: singletons, which consist of a single unit, lead units, which come first in a multiunit sequence, and trail units, which come afterwards in a multiunit sequence. Input and display software obviously needs to know about the structure of the multibyte encoding scheme but other software generally doesn't need to know if a pair of bytes represent two separate characters or just one character.

...

UTF-8 makes it easy for a program to identify the three sorts of units, since they fall into separate value ranges.

...

The Unicode standard has two variable-width encodings: UTF-8 and UTF-16 (it also has a fixed-width encoding, UTF-32).
... in [UTF-8] singletons have the range 00-7F, lead units have the range C0-FD (now actually C2-F4...), and trail units have the range 80-BF. The lead unit also tells how many trail units follow: one after C2-DF, two after E0-EF and three after F0-F4.

- wikipedia.org

Unicode

UTF-8, most frequently used specification

The frustrating dilemma that researchers in this field encountered in the 1980s as they tried to develop universally interchangeable character encodings was that on the one hand, it seemed to be necessary to add more bits to accommodate additional characters. On the other hand, for the users of the relatively small character set of the Latin alphabet (who still constituted the majority of computer users at the time), those additional bits were a colossal waste of then-scarce and expensive computing resources (as they would always be zeroed out for such users).

The compromise solution that was eventually hit upon with Unicode, as further explained below, was to break the longstanding assumption (dating back to the old telegraph codes) that each character should always directly correspond to a particular pattern of encoded bits. Instead, characters would be first mapped to an intermediate stage in the form of abstract numbers known as code points. Those code points would then be encoded in a variety of ways and with various default numbers of bits per character (code units) depending upon context. To encode code points higher than the length of the code unit, such as above 256 for 8-bit units, the solution was to implement variable-width encodings where an escape sequence would signal that subsequent bits should be parsed as a higher code point.

- wikipedia.org

referencing Unicode characters

Newline (EOL) Characters

In computing, a newline, also known as a line ending, end of line (EOL), or line break, is a special character or sequence of characters signifying the end of a line of text. The actual codes representing a newline vary across operating systems...

Two ways to view newlines... are that newlines terminate lines or that they separate lines.

- wikipedia.org
end of line conventions
OSASCII dec#ASCII hex#Symbolmost programming
Unix & Unix-like100aLF\n
Windows13, 100d, 0aCR/LF\r\n
Mac Classic (pre-OS X)130dCR\r

Web Authoring essentials

FTP, HTTP

An FTP site is
a computer that is running FTP server software
(aka an FTP daemon, or ftpd).

RFC114 (1971)

history, terminology, model (1985)

FTP mini-HOWTO

If you're still using FTP, however, please consider switching to HTTP. FTP is a protocol designed for a different era -- these days everyone should be avoiding it for multiple reasons.

- kernel.org
HTTP (1991)
HTTP/1.1 (1999)
how Web servers work

HTML

new semantic elements
header
nav
sectionaside
article
footer

POSH ("Plain Old Semantic HTML")

HTML elements reference

WHATWG Living Standard (first published in 2012)

HTML comment: <!--    --> (single-line and multi-line) (whitespace required after opening and before closing tag)

Empty elements
elements with no content, and no end tag
  • area
  • base
  • br
  • col
  • embed
  • hr
  • img
  • input
  • keygen
  • link
  • meta
  • param
  • source
  • track
  • wbr

Empty elements can be "closed" in the opening tag like this: <br />

HTML5 does not require empty elements to be closed. But if you want stricter validation, or you need to make your document readable by XML parsers, you should close all HTML elements.

- w3schools.com
Text-level semantics
These are inline elements, used to mark up bits of text giving them machine-readable meaning. For example, to specify a date or time, use the
  • time
element.

https://html.spec.whatwg.org/multipage/text-level-semantics.html

Table elements
  • table
  • caption
  • colgroup
  • col
  • thead
  • tbody
  • tfoot
  • tr
  • th
  • td

The tbody element is used in conjunction with the thead and tfoot elements

Browsers can use these elements to enable scrolling of the table body independently of the header and footer.

- w3schools.org
attributes of table cells
These are HTML (structural) attributes, not to be confused with CSS (style) attributes.
  • colspan
  • rowspan
Headings

The h1h6 elements are headings.

The first element of heading content in an element of sectioning content represents the heading for that section. Subsequent headings of equal or higher rank start new (implied) sections, headings of lower rank start implied subsections that are part of the previous one. In both cases, the element represents the heading of the implied section.

- This was from a w3.org page which is no longer available.
Grouping Content
  • body
  • main
  • div
  • p
  • hr
  • pre
  • blockquote
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • figure
  • figcaption
new in html5:
  • article
  • aside
  • footer
  • header
  • nav
  • section

Using HTML section semantics

DOM

DOM

Now that the World Wide Web Consortium seems to have taken down their website at w3.org, where do we look for a standard? The WHATWG (Web Hypertext Application Technology Working Group) has this page: spec.whatwg.org  What about a CSS standard?

The DOM is a Mess (2009, jQuery creator John Resig)

DOM Level 3, the current release of the DOM specification, published in April 2004
DOM Level 4 is currently being developed.
Last Call Working Draft was released in February 2014.

In-Memory Representation of Document Structure

The in-memory representation is known as DOM HTML, or the DOM for short.

There are various concrete syntaxes that can be used to transmit resources that use this abstract language, two of which are defined in this specification.

The first such concrete syntax is the HTML syntax. This is the format suggested for most authors. It is compatible with most legacy Web browsers. If a document is transmitted with the text/html MIME type, then it will be processed as an HTML document by Web browsers. This specification defines the latest HTML syntax, known simply as HTML.

The second concrete syntax is the XHTML syntax, which is an application of XML. When a document is transmitted with an XML MIME type, such as application/xhtml+xml, then it is treated as an XML document by Web browsers, to be parsed by an XML processor.

- WHATWG

Let's say you open a web browser... and load a web page in it... Now, inside the browser, there is a window object. This object represents the browser window.

This window object has dozens of properties (members), the most important of them being the document object. The document object represents the web page that is currently loaded into the browser window.

A node is an object that is "connected" to other objects from the DOM tree.

The JavaScript programs that are bound to a web page have complete access to every node of the DOM tree. They can delete nodes, add new nodes, or just manipulate the properties of a node.

...

HTML describes the structure of a document. The browser parses HTML and constructs an internal representation of the elements of the document from it

This internal representation is the DOM, the Document Object Model. This is the basis for creating the actual visual representation of the website.

- stackoverflow.com

The DOM for a webpage differs from the page source HTML for various reasons, e.g.:

  • Scripts in the page can manipulate the DOM (add/delete/modify nodes).
  • A <table> element requires (in the DOM) a <tbody> child element. If the page source HTML doesn't have one, the browser will put one into the DOM for the page.

The browser will just insert that <tbody> for you. It will be there in the DOM, so you'll be able to find it with JavaScript and style it with CSS, even though it's not in your HTML.

- css-tricks.com
Legacy DOM (1995-96)

Legacy DOM was limited in the kinds of elements that could be accessed. Form, link and image elements could be referenced with a hierarchical name that began with the root document object. A hierarchical name could make use of either the names or the sequential index of the traversed elements. For example, a form input element could be accessed as either document.formName.inputName or document.forms[0].elements[0].

The Legacy DOM enabled client-side form validation and the popular "rollover" effect.

- wikipedia.org

CSS

Levels history

CSS 2.1

CSS level 2 revision 1...went back and forth between Working Draft status and Candidate Recommendation status for many years... Candidate Recommendation...2004... it was finally published as a W3C Recommendation on 7 June 2011.

CSS 3

Unlike CSS 2, which is a large single specification defining various features, CSS 3 is divided into several separate documents called "modules"... The earliest CSS 3 drafts were published in June 1999.

Due to the modularization, different modules have different stability and statuses. As of June 2012, there are over fifty CSS modules published from the CSS Working Group, and four of these have been published as formal Recommendations:

  • 2012-06-19: Media Queries
  • 2011-09-29: Namespaces
  • 2011-09-29: Selectors Level 3
  • 2011-06-07: Color

Some modules (including Backgrounds and Borders and Multi-column Layout among others) have Candidate Recommendation (CR) status and are considered moderately stable.

CSS 4

Because CSS3 split the CSS language's definition into modules, the modules have been allowed to level independently. Most modules are level 3... A few level-4 modules exist (such as Image Values, Backgrounds & Borders, or Selectors), which build on the functionality of a preceding level-3 module. Other modules defining entirely new functionality, such as Flexbox, have been designated as "level 1".

So, although no monolithic CSS4 will be worked on after CSS3 is finished completely, the level 4 modules can collectively be referred to as CSS4.

- wikipedia.org
Selectors
  • type (element type)
  • universal *
  • attribute [ ]
  • class .
  • id #
  • contextual combinators >  +~
    (child, descendant, adjacent sibling, sibling)
    e.g. div * p selects any p element descendent from a descendant of a div element.
  • pseudo-element
    not all style properties apply
    • ::first-letter
    • ::first-line
    • ::before
    • ::after
    • ::selection

  • pseudo-class
    these must be styled in the given order to be effective
    • a:link
    • a:visited
    • a:hover
    • a:active

    there are many more pseudo-elements, e.g.:
    • :valid
    • :invalid
    • :first-child
    • :nth-child

CSS will typically style a tag using the most specific DOM description that can be applied to it.

- stackoverflow.com
Syntax
A CSS rule set consists of:
selector(s) {declaration(s)}
h1, h2 {color: maroon; text-align: center;}

comment: /*    */ (single-line and multi-line)

Properties acc to Whether Inherited by Default
inherited
  1. azimuth
  2. border-collapse
  3. border-spacing
  4. caption-side
  5. color
  6. cursor
  7. direction
  8. elevation
  9. empty-cells
  10. font-family
  11. font-size
  12. font-style
  13. font-variant
  14. font-weight
  15. font
  16. letter-spacing
  17. line-height
  18. list-style-image
  19. list-style-position
  20. list-style-type
  21. list-style
  22. orphans
  23. pitch-range
  24. pitch
  25. quotes
  26. richness
  27. speak-header
  28. speak-numeral
  29. speak-punctuation
  30. speak
  31. speech-rate
  32. stress
  33. text-align
  34. text-indent
  35. text-transform
  36. visibility
  37. voice-family
  38. volume
  39. white-space
  40. widows
  41. word-spacing
not inherited
  1. background-attachment
  2. background-color
  3. background-image
  4. background-position
  5. background-repeat
  6. background
  7. border-color
  8. border-style
  9. border-top
  10. border-right
  11. border-bottom
  12. border-left
  13. border-top-color
  14. border-right-color
  15. border-bottom-color
  16. border-left-color
  17. border-top-style
  18. border-right-style
  19. border-bottom-style
  20. border-left-style
  21. border-top-width
  22. border-right-width
  23. border-bottom-width
  24. border-left-width
  25. border-width
  26. border
  27. bottom
  28. clear
  29. clip
  30. content
  31. counter-increment
  32. counter-reset
  33. cue-after
  34. cue-before
  35. cue
  36. display
  37. float
  38. height
  39. left
  40. margin-right
  41. margin-left
  42. margin-top
  43. margin-bottom
  44. margin
  45. max-height
  46. max-width
  47. min-height
  48. min-width
  49. outline-color
  50. outline-style
  51. outline-width
  52. outtline
  53. overflow
  54. padding-top
  55. padding-right
  56. padding-bottom
  57. padding-left
  58. padding
  59. page-break-after
  60. page-break-before
  61. page-break-inside
  62. pause-after
  63. pause-before
  64. pause
  65. play-during
  66. position
  67. right
  68. table-layout
  69. text-decoration
  70. top
  71. unicode-bidi
  72. vertical-align
  73. width
  74. z-index
CSS 3 (partial list of new properties)
  1. box-sizing: border-box
  2. -moz-box-sizing: border-box
  3. -webkit-box-sizing: border-box
  4. column-count
  5. -moz-column-count
  6. -webkit-column-count
  7. column-fill
  8. column-gap
  9. column-rule-style
  10. column-rule-width
  11. column-rule-color
  12. column-rule
  13. column-span
  14. column-width
  15. columns
  16. (@keyframes <name> { })
  17. animation-name
  18. animation-duration
  19. animation-delay
  20. animation-iteration-count
  21. animation-direction
  22. animation-timing-function
  23. animation
  24. animation-fill-mode
  25. animation-play-state
  26. border-top-left-radius
  27. border-top-right-radius
  28. border-bottom-right-radius
  29. border-botton-left-radius
  30. border-radius
  31. border-image-source
  32. border-image-slice
  33. border-image-width
  34. border-image-outset
  35. border-image-repeat
  36. border-image
  37. background-clip
  38. background-origin
  39. background-size
  40. opacity
  41. linear-gradient
  42. radial-gradient
  43. repeating-linear-gradient
  44. repeating-radial-gradient
  45. box-shadow
  46. text-shadow
  47. text-align-last
  48. text-emphasis-style
  49. text-emphasis-color
  50. text-emphasis
  51. text-justify
  52. text-overflow
  53. word-break
  54. word-wrap
  55. (@font-face)
  56. src
  57. font-stretch
  58. unicode-range
  59. (2D transforms)
  60. (3D transforms)
  61. (transitions)
  62. (user interface)
  63. (responsive web design)
  64. more
Attributes (properties) useful in styling tables and cells (table, th, td elements)
  • inherited:
    • border-collapse
    • border-spacing
    • text-align
  • not inherited:
    • border
    • padding
    • vertical-align
Centering and Positioning

to center a block element having width set to < 100%: margin: auto

centering in CSS

how to center in CSS

relationships between 'display', 'position', and 'float'

Tip: When aligning elements with position or with float, always define margin and padding for the body element. This is to avoid visual differences in different browsers.

Box Model

width's big caveat: the box model adds padding and border-width
solution: use the experimental new box-sizing: border-box;
Since small is pretty new, you should use the -webkit- and -moz- prefixes for now

Inline elements: respect left & right margins and padding, but not top & bottom; cannot have a width and height set; allow other elements to sit to their left and right.

Inline-block elements: allow other elements to sit to their left and right; respect top & bottom margins and padding; respect height and width

Block elements: respect all of those; force a line break after the block element

- stackoverflow.com
Flexible Box

The CSS3 Flexible Box, or flexbox, is a layout mode providing for the arrangement of elements on a page such that the elements behave predictably when the page layout must accommodate different screen sizes and different display devices. For many applications, the flexible box model provides an improvement over the block model in that it does not use floats, nor do the flex container's margins collapse with the margins of its contents.

The defining aspect of the flex layout is the ability to alter its items' width and/or height to best fill the available space on any display device. A flex container expands items to fill available free space, or shrinks them to prevent overflow.

The flexbox layout algorithm is direction-agnostic as opposed to the block layout, which is vertically-biased, or the inline layout, which is horizontally-biased.

- developer.mozilla.org

JavaScript - see under Programming Languages below

Performance

webpage size breakdown
avg page now > 2 MB
bandwidth
latency
images
tools
 the average web site has become way overtooled, which exacts a price when it comes to speed.

Website User Experience

DBMS

In computer science, ACID (Atomicity, Consistency, Isolation, Durability) is a set of properties that guarantee that database transactions are processed reliably.

Ted Codd, and the Relational Model

  • A Relational Model of Data for Large Shared Data Banks (1970)
  • relation as a set of tuples (informal: "records")
  • tuple as a set of attribute values (informal: "fields")
    Finitary relation (? needs clarification re db ?) - wikipedia.org
  • note: In other (non-db) mathematical contexts, A tuple is a finite ordered list of elements. - wikipedia.org
  • however: In database context, a tuple is a finite unordered group of elements. - Ted Codd, Chris Date, Fabian Pascal
    • (tables, rows, columns) imperfectly represent (relations, tuples, attributes) of a db, because sets have no order, and no duplication.

In mathematics, a set is a collection of distinct objects...
... two sets are equal (one and the same) if and only if every element of each set is an element of the other.

- wikipedia.org

What, then, is an attribute? - an attribute name plus its associated value within a particular tuple?

SQL

         Data types (declared in CREATE TABLE) included in ANSI SQL:
 Character string
  CHAR(n) / VARCHAR(n)
 Bit string
  BIT(n) / BIT VARYING(n)	(array of bits)
 Number
  INTEGER / SMALLINT / BIGINT
  FLOAT / REAL / DOUBLE PRECISION
  NUMERIC(precision, scale)  or  DECIMAL(precision, scale)	e.g. 123.45 has precision 5, scale 2
 Date and time

Language elements
• Clauses
• Expressions	can produce either scalar values, or tables
• Predicates	WHERE ___
• Queries
• Statements	terminated by ;
• Insignificant whitspace

*********************** DDL ***********************
CREATE/DROP DATABASE
CREATE/DROP TABLE | VIEW	NOT NULL	UNIQUE		PRIMARY KEY	FOREIGN KEY
RENAME TABLE ?
ALTER TABLE

************** Transaction controls **************
Transactions, if available, wrap DML operations:
START TRANSACTION
SAVE TRANSACTION
COMMIT
ROLLBACK


*********************** DML ***********************
INSERT INTO [table] ([columns])
  VALUES ('  ', '  ', '  ')	/  VALUES (  ,  ,  )
UPDATE
  SET ..='  ' WHERE ..='  '	/  SET ..=.. WHERE ..
MERGE ?
DELETE FROM .. WHERE
TRUNCATE TABLE
SELECT .. FROM
SELECT DISTINCT .. FROM  (otherwise it can return a non-relation)
SELECT is the most complex statement in SQL, with optional keywords and clauses that include:

examples:
 SELECT * FROM Persons WHERE FirstName LIKE 'a%' AND/OR ..
 SELECT * FROM Persons WHERE FirstName='Peter' AND LastName="Jackson'
 SELECT * FROM Persons WHERE FirstName BETWEEN 'Hansen' AND 'Petterson' ORDER BY Salary DESC
 SELECT .. .. GROUP BY .. HAVING
 SELECT .. .. [NATURAL/INNER/OUTER]? JOIN .. ON
 SELECT COUNT(*) FROM Persons

operators: BETWEEN..AND, LIKE..%
functions: AVG, COUNT, SUM, .. TRUNC/ROUND rounds numerics or dates (in Postgres and various DBMSs)


*********************** DCL ***********************
GRANT
REVOKE


*********************** ext ***********************

Procedural extensions
SQL is designed for a specific purpose: to query data contained in a relational database. SQL is a set-based, declarative programming language, not an imperative programming language like C or BASIC. However, extensions to Standard SQL add procedural programming language functionality, such as control-of-flow constructs. These include:
Source			Common name		Full name
ANSI/ISO Standard	SQL/PSM		SQL/Persistent Stored Modules
PostgreSQL		PL/SQL		Procedural Language/SQL (based on Ada)
PostgreSQL		PL/PSM		Proc Lang/Pers St Mod
In addition to the standard SQL/PSM extensions and proprietary SQL extensions, procedural and object-oriented programmability is available on many SQL platforms via DBMS integration with other languages. ... PostgreSQL lets users write functions in a wide variety of languages‚ including Perl, Python, Tcl, and C.


         

SQL deviates in several ways from its theoretical foundation, the relational model and its tuple calculus. In that model, a relation is a set of tuples, while in SQL, tables and query results are lists of rows: the same row may occur multiple times, and the order of rows can be employed in queries (e.g. in the LIMIT clause).

PostgreSQL

  • emphasis on extensibility and on standards-compliance
  • can handle workloads ranging from small single-machine applications to large Internet-facing (Web service) applications with many concurrent users
  • implements the majority of the SQL:2011 standard
  • is ACID-compliant
  • avoids locking issues using multiversion concurrency control (MVCC)
  • updateable views
  • snapshots ("materialized views")
  • cross-platform
  • the vast majority of Linux distributions have it available in supplied packages.
  • developed by the PostgreSQL Global Development Group, a diverse group of many companies and individual contributors.
  • free and open-source software, released under the terms of the PostgreSQL License, a permissive free-software license.
  • Database-SQL-RDBMS HOW-TO document for Linux

x86 Assembly language

Modular arithmetic used to be something that every programmer encountered because it is part of the hardware of every machine. You find it in the way numbers are represented in binary and in machine code or assembly language instructions.

Once you get away from the representation of numbers as bit strings and arithmetic via registers then many mod and remainder operations lose their immediate meaning so familiar to assembly language programmers.

As soon as you start implementing even the simplest of algorithms the need to understand mod will occur.

- i-programmer.info

Regular Expressions

Learn regular expressions in about 55 minutes

man grep good coverage of RE

Programming languages

C (1972)

Perl (1987)

.string concatenation operator

xstring repition operator

various ways to concatenate:

  • $filename = "/tmp/${name}.tmp";
  • $filename = '/tmp/' . $name . '.tmp'
  • $filename = join('', '/tmp/' ,$name, '.tmp')

#single-line comment

multi-line comment

Unlike many programming languages Perl does not currently implement true multiline comments. This, and the workarounds that are in common use can be problematic. This could be solved by adding a new syntax...

The alternatives available to Perl programmers however are neither easy (comment each and every line of code individually..., nor consistent (use some other language feature to simulate multiline comments, like POD [Plain Old Documentation]).

What's Wrong With POD?

  • it's not intuitive
  • it's not documentation
    ... most of the time comments are not intended to be included in the documentation (separate from the code). This is particularly true when using comments as a debugging tool.
  • it doesn't encourage consistency

learn.perl.org
perlmonks.org
stackoverflow.com

Perl, by default, does not have any specific tokens to specify multiline comments. Nevertheless, there are several workarounds to accomplish this.

The easiest solution is to use the POD [Plain Old Documentation] system, enclosing the comments between 2 lines: the first line should begin with '=comment' and the last line should begin with '=cut'.

...

Perl has rather inflexible and limited comments. The desire to preserve compatibility with shell languages dictated the use of #, but here Perl robbed itself of [an] important symbol (that can be used, for example for casting scalars into numeric).

- perlhowto.com
Data structures
  • scalar
  • array
  • hash
Tutorials

Python (1991)

__

PHP (1995)

.string concatenation operator

// or #single-line comment
/* to */multi-line comment

JavaScript (1995)

"use strict";

BOM
window
    properties:
    	global variables
    	global objects
    	innerWidth, innerHeight
        document, location, history, screen, navigator*
            - document.getElementById("abc")
              document.getElementsByTagName("h2")
              document.getElementsByClass("class1")
              document.getElementsByName("name1")
              document.querySelectorAll() ?
            - location.href/hostname/pathname/protocol/assign(load doc)
            - history.back()/forward()
            - screen.width/height/availWidth/availHeight/colorDepth=pixelDepth
            - navigator.appName/appCodeName/platform/cookieEnabled/product
              (engine)/appVersion/userAgent(v detail)/language/javaEnabled()
                * different browsers can use the same name
                * navigator data can be changed by browser owner
                * some browsers misidentify themselves to bypass site tests
                * browsers cannot report new operating systems (released later)
    methods:
        global functions
        open(), close(), moveTo(), resizeTo()
        alert(), confirm(), prompt()
        setInterval(), clearInterval(), setTimeout(), clearTimeout()

    (window properties and methods can be written without the window. prefix)


document.cookie
    JS can create, read, and delete cookies with this property.
    document.cookie="username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC;
     path=/";
    document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC"; path=;
    document.cookie will return all cookies in one string much like:
        cookie1=value; cookie2=value; cookie3=value;



There are no official standards for the Browser Object Model (BOM).

Since modern browsers have implemented (almost) the same methods and properties
 for JavaScript interactivity, it is often referred to, as methods and
 properties of the BOM.
 [- w3schools.org]


https://www.youtube.com/watch?v=dgI52y27O_I
49:00- top-down CSS selector
51:00- bottom-up - how CSS selectors are implemented in browsers (CSS selector
 engines) -- sometimes this style is faster

           
Data Types
  • boolean
  • number
    (64-bit floating point)
  • string
  • object
    • Object
    • Date
    • Array
  • function
  • undefined
  • null
    (undefined == null)   true
    (undefined === null) false

JS types are "dynamic"--the same variable can be used as different types

dynamic typing
types associated with values, not w/ variables
<value>typeof <value>
trueboolean
1.11number
Math.PInumber
Number.MAX_VALUEnumber
"1.1"string
Date()string
new Date()object
{name:"Joe", gender:"m"}object
[1,2,"abc"]object
evalfunction
undefinedundefined
nullobject ?!
Syntax
  • use semicolon ; at the end of each simple statement
  • use semicolon ; at the end of object, date object, array definitions
  • no semicolon at the end of functions, conditionals, loops
  • single-line comment://
  • multi-line comment:/*    */
Misc
  • In HTML the default global object is the HTML page itself, so the function above "belongs" to the HTML page. In a browser the page object is the browser window. The function above automatically becomes a window function. myFunction() and window.myFunction() is the same function.
  • This is a common way to invoke a JavaScript function, but not a good practice in computer programming. Global variables, methods, or functions can easily create name conflicts and bugs in the global object.
  • Invoking a function as a global function, causes the value of this to be the global object. Using the window object as a variable can easily crash your program.
  • In JavaScript you can define functions as object methods.
  • The thing called this, is the object that "owns" the JavaScript code.
  • With call() or apply() you can set the value of this, and invoke a function as a new method of an existing object.
  • using this
  • best practices: avoid global variables, declarations on top, initialize, avoid new ( Boolean(), Number(), String(), Object(), Array(), RegExp(), function ), use parameter defaults, avoid ==, avoid eval()

object-based

runtime evaluation (eval function)

objects are prototype-based (classless; instance-based)

supports functional programming (declarative; referential transparency)

Official ECMAScript Reserved Words
  • abstract
  • arguments
  • boolean
  • byte
  • var
  • new
  • typeof
  • null
  • short
  • long
  • double
  • float
  • true
  • false
  • try
  • throw
  • catch
  • finally
  • debugger
  • throws
  • function
  • return
  • if
  • else
  • switch
  • case
  • break
  • default
  • for
  • in
  • do
  • while
  • continue
  • goto

learn about:
abstract, arguments, byte, char, class*, const, delete, eval, export*, extends*, final, implements, import*, instanceof, int, interface, let, native, package, private, protected, public, static, super*, synchronized, this, transient, void, volatile, with, yield

Quick Guide

+string concatenation and number addition operator

developed by ECMA

ECMAScript®2015 Language Specification

script
a program that doesn't need pre-processing (e.g. compiling) before being run. - w3.org

JavaScript and Java are completely different languages, both in concept and design. JavaScript was invented by Brendan Eich in 1995, and became an ECMA standard in 1997. ECMA-262 is the official name. ECMAScript 5 (JavaScript 1.8.5 - July 2010) is the current standard.

- w3schools.org

The World Wide Web Consortium (W3C), founded in 1994 to promote open standards for the World Wide Web, brought Netscape Communications and Microsoft together with other companies to develop a standard for browser scripting languages, called ECMAScript. The first version of the standard was published in 1997.

- wikipedia.org

JavaScript statements

most misunderstood language

JavaScript overview

CGI on Linux Apache web server

print("Content-type: text/html\n\n");

Writing a CGI program

log files

current CGI specification

HTML Writers Guild