Ict L1

Cards (34)

  • JavaScript
    The most popular and widely used scripting language on the internet, and is recognized and works in all major browsers
  • Scripting language
    It is interpreted by another program at runtime rather than compiled by the computer's processor as other programming languages
  • JavaScript
    It was developed by Brendan Eich of Netscape under the name Mocha, which was later renamed to LiveScript then to JavaScript
  • JavaScript was first introduced and deployed in the Netscape browser version 2.0B in December 1994
  • Netscape submitted JavaScript to Ecma International for standardization resulting in the standardized version named ECMAScript
  • JavaScript
    It is a client-side, high-level scripting, interpreted, and object-oriented language designed to add interactivity and functionality to the web site
  • Client-side
    Codes and formulas are processed right on the user's computer
  • High-level scripting
    Codes are written in words that are close to English as possible
  • Interpreted
    The program is passed as source code then converted into machine code as it is being used
  • Object
    Refers to a person, place, or thing
  • Properties
    Attributes and description of an object
  • Methods
    Actions that an object can perform
  • Parameters
    Values or instructions that will be used inside the method
  • JavaScript is case-sensitive so be careful when you type the syntax and other names
  • Missing and unbalanced quotation marks cause the browser from loading and displaying properly
  • Semi-colons at the end of each statement are not required, but it is ideal to place it for readability and to standardize your codes
  • What JavaScript can do
    • React to events
    • Validate data
    • Create cookies
    • Enhance a web page
  • Features of JavaScript
    • Supports all structure programming syntax in C
    • Has dynamic typing
    • Can run locally in a web site, so interaction within the user and the site is faster or more responsive
    • Can detect user actions, such as mouse clicks, which HTML could do not alone
    • Can be combined with CSS to produce DHTML
  • Disadvantages of JavaScript
    • Some browsers do not support JavaScript
    • Any secret embedded in JavaScript could be extracted by a determined adversary
    • JavaScript and DOM (Document Object Model) provide the potential for malicious authors to deliver scripts to run on a client computer via the web
    • Web site authors cannot perfectly conceal how their JavaScript operates, because the code is sent to the client
    • Source code that have been deliberately made hard to understand can be reverse engineered so your codes are still exposed to possible threats
  • How to start using JavaScript
    1. <script></script> is used to connote JavaScript
    2. Use the type attribute to define the scripting language and identify its version
    3. The document.write command should be used when you want to display an output on the webpage
  • document.write
    • Hi
  • document
    Object name
  • Hi
    Parameter that holds the instruction
  • Commonly used properties and methods
    • Window
    • Document
    • Math
    • Navigator
  • Window object
    The main object, many of its properties can be used in their own right such as document, frame, and location
  • Document object
    The container for all HTML, HEAD and BODY objects associated within the HTML tags of the HTML documents
  • Math object
    Provides the capability to perform math operations
  • Navigator object
    Determines which browser is running
  • Syntax for creating an event
    1. <tag attribute eventHandler="function/JavaScript code">
    2. Event - result of a user's action
    3. Event Handlers - way to connect that action to a function or a set of JavaScript codes to be executed
  • Where can you place Scripts
    • Head
    • Body
    • Head and Body
    • External JavaScript
  • External JavaScript
    Very helpful especially if you are using them to control different HTML files, saves you from rewriting the same code
  • JavaScript Guidelines
    • Case Sensitive
    • White Space
    • Breaking up of code lines
  • JavaScript ignores white space as long as it is within the line of code, but it is a good practice to use white spaces between expressions to make your codes easier to read
  • You can break a code line by using a backslash ('\'), but do not break the code in between commands or else it will not work properly