CS202 Mid term
267 Questions
27 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the result of calling toCelsius(32)?

  • 0 (correct)
  • 100
  • 32
  • 273.15
  • What happens if you use toCelsius without parentheses?

  • It produces an error.
  • It calls the function and executes it.
  • It returns the value 0.
  • It returns the function definition. (correct)
  • Which statement accurately describes local variables in JavaScript?

  • They must be declared as global to be used within a function.
  • They are created when a function starts and deleted when it completes. (correct)
  • They are accessible from outside the function in which they are declared.
  • They can be accessed globally throughout all functions.
  • What is the main purpose of JavaScript objects?

    <p>To act as containers for named values, called properties and methods.</p> Signup and view all the answers

    What is a characteristic of global variables?

    <p>They can be accessed by any script or function on the web page.</p> Signup and view all the answers

    What will happen if a value is assigned to an undeclared variable?

    <p>It will automatically become a global variable.</p> Signup and view all the answers

    What is the scope of variables defined within a function?

    <p>It has a local scope only within that function.</p> Signup and view all the answers

    How can functions be utilized in JavaScript?

    <p>In any place where a variable can be used.</p> Signup and view all the answers

    What will be the value of z after executing var x = 5 + 2 + 3; var y = 2; var z = x + y;

    <p>12</p> Signup and view all the answers

    What happens when you add a number and a string in JavaScript?

    <p>It returns the concatenated string.</p> Signup and view all the answers

    Which statement correctly defines a JavaScript function?

    <p>function name(parameter1, parameter2) { code }</p> Signup and view all the answers

    When is the code inside a JavaScript function executed?

    <p>When an event occurs or when invoked.</p> Signup and view all the answers

    Which of the following statements about the += operator in JavaScript is accurate?

    <p>It adds or concatenates values.</p> Signup and view all the answers

    What is not a reason for using functions in JavaScript?

    <p>To create global variables.</p> Signup and view all the answers

    How are function parameters different from function arguments?

    <p>Parameters are defined in the function; arguments are provided during invocation.</p> Signup and view all the answers

    What will the result be when executing the statement y = '5' + 5?

    <p>'55'</p> Signup and view all the answers

    Which method can be used to break up a long string safely in JavaScript?

    <p>Using string addition</p> Signup and view all the answers

    What will the result of the expression (x == y) be if x is a string and y is a String object?

    <p>true</p> Signup and view all the answers

    How does the === operator differ from the == operator in JavaScript?

    <p>=== checks both type and value, while == checks only the value</p> Signup and view all the answers

    What type will the variable 'x' have when assigned using var x = ‘Mike’?

    <p>string</p> Signup and view all the answers

    What will happen if you attempt to split a line using a backslash in JavaScript code?

    <p>It will throw a syntax error</p> Signup and view all the answers

    What is the correct way to represent the number 12300000 in JavaScript?

    <p>var x = 123e5;</p> Signup and view all the answers

    How is the maximum number of decimal digits that JavaScript can accurately represent classified?

    <p>15 digits for integers.</p> Signup and view all the answers

    Which of the following statements is true about primitive strings in JavaScript?

    <p>They are treated as objects when executing methods and properties</p> Signup and view all the answers

    What will typeof return for a string defined as an object using 'new String()'?

    <p>object</p> Signup and view all the answers

    What will the value of 'x' be after executing 'var x = 0.2 + 0.1;'?

    <p>0.30000000000000004</p> Signup and view all the answers

    What is the result of dividing a number by zero in JavaScript?

    <p>Infinity</p> Signup and view all the answers

    Which statement is accurate regarding how JavaScript treats numbers?

    <p>Numbers can be written with or without decimals</p> Signup and view all the answers

    What does 'NaN' represent in JavaScript?

    <p>Not a Number.</p> Signup and view all the answers

    How are hexadecimal numeric constants denoted in JavaScript?

    <p>With the prefix '0x'.</p> Signup and view all the answers

    What is the main format in which JavaScript stores all numbers?

    <p>64-bit floating point.</p> Signup and view all the answers

    What type of value does 'typeof Infinity' return in JavaScript?

    <p>number</p> Signup and view all the answers

    What will be the length of the array after adding 'Lemon' to the fruits array?

    <p>5</p> Signup and view all the answers

    What kind of indexes does JavaScript arrays use?

    <p>Numbered indexes</p> Signup and view all the answers

    Which of the following statements about JavaScript's associative arrays is correct?

    <p>JavaScript does not support associative arrays.</p> Signup and view all the answers

    What will be the output of the variable 'y' after the following code executes: var person = []; person = 'Adil'; person = 'Anwar'; person = 46; var y = person;

    <p>46</p> Signup and view all the answers

    Which of the following is NOT a reason to avoid using the 'new Array()' statement?

    <p>It creates an array with fewer elements.</p> Signup and view all the answers

    Which method is recommended to add a new element to an array in JavaScript?

    <p>Using the length property</p> Signup and view all the answers

    What is the correct way to create an empty array in JavaScript?

    <p>var emptyArray = [];</p> Signup and view all the answers

    Which loop is best suited for iterating through an array in JavaScript?

    <p>For loop</p> Signup and view all the answers

    What will the value of z be after executing var x = 5 + 2 + 3; var y = 2; var z = x + y;

    <p>12</p> Signup and view all the answers

    What is the primary purpose of the return statement in a JavaScript function?

    <p>To stop the execution of the function</p> Signup and view all the answers

    Which operator can be used to concatenate two strings in JavaScript?

    <ul> <li></li> </ul> Signup and view all the answers

    What will be the result when a number and a string are added in JavaScript?

    <p>A string</p> Signup and view all the answers

    Which of the following would result in a valid function definition?

    <p>function myFunction() { }</p> Signup and view all the answers

    How can you add a value to an existing string variable in JavaScript?

    <p>txt += 'new value';</p> Signup and view all the answers

    What does the 'function invocation' refer to in JavaScript?

    <p>The execution of a function code block</p> Signup and view all the answers

    Which of the following statements about variables in JavaScript is true?

    <p>Variables can store different types of data</p> Signup and view all the answers

    What will happen if a line of code in JavaScript starts with a comment?

    <p>The code will be ignored and not executed.</p> Signup and view all the answers

    Which of the following is a true statement regarding the case sensitivity of JavaScript identifiers?

    <p>The identifiers lastName and lastname are two different variables.</p> Signup and view all the answers

    What is the commonly accepted format for variable naming in JavaScript when using multiple words?

    <p>Using camel case typically starting with a lowercase letter.</p> Signup and view all the answers

    How are multiple statements handled in a single line in JavaScript?

    <p>They must be separated by semicolons.</p> Signup and view all the answers

    What is the role of Unicode in JavaScript?

    <p>It provides a character set that covers most symbols and characters worldwide.</p> Signup and view all the answers

    What is the purpose of a semicolon in a JavaScript statement?

    <p>To end and separate distinct statements.</p> Signup and view all the answers

    How does JavaScript interpret white space in code?

    <p>It ignores multiple spaces for readability purposes.</p> Signup and view all the answers

    What is generally recommended regarding line length for better readability in JavaScript?

    <p>Lines should not exceed 80 characters.</p> Signup and view all the answers

    What is the default date representation when using new Date() with no parameters?

    <p>The current date and time</p> Signup and view all the answers

    Which method correctly converts a date to a UTC string?

    <p>toUTCString()</p> Signup and view all the answers

    When creating a Date object to represent 'October 13, 2014 11:13:00', which syntax is correct?

    <p>new Date('October 13, 2014 11:13:00')</p> Signup and view all the answers

    What does the zero time reference in JavaScript correspond to?

    <p>January 1, 1970 00:00:00 UTC</p> Signup and view all the answers

    Which statement about the use of new Date(milliseconds) is accurate?

    <p>It creates a date object starting from zero time plus the specified milliseconds.</p> Signup and view all the answers

    When using new Date(year, month, day), what is the range of the month value?

    <p>0 to 11</p> Signup and view all the answers

    What will the following code output? 'var d = new Date(86400000); document.getElementById("demo").innerHTML = d;'

    <p>A date object representing January 2, 1970</p> Signup and view all the answers

    Which of the following is NOT an allowable parameter when creating a Date object using new Date(year, month, day, hours, minutes, seconds, milliseconds)?

    <p>total days</p> Signup and view all the answers

    What will the result of evaluating 100 / 'Apple' be in JavaScript?

    <p>NaN</p> Signup and view all the answers

    When comparing two number objects using the == operator, what will be the result?

    <p>True, because their values are equal</p> Signup and view all the answers

    What happens when you use the === operator to compare a primitive number and a number object?

    <p>It returns false due to different types</p> Signup and view all the answers

    Which of the following statements is true regarding JavaScript number methods?

    <p>They return a new value without modifying the original</p> Signup and view all the answers

    What is the main purpose of code blocks in JavaScript?

    <p>To group statements to be executed together</p> Signup and view all the answers

    Which of the following is true about JavaScript comments?

    <p>Single line comments start with //</p> Signup and view all the answers

    Which method will convert a number to a string representation in JavaScript?

    <p>toString()</p> Signup and view all the answers

    If you create a number as an object using new Number(500), what type will it be?

    <p>Number Object</p> Signup and view all the answers

    Which of these statements about JavaScript identifiers is correct?

    <p>Identifiers can include letters, digits, underscores, and dollar signs</p> Signup and view all the answers

    What does the equal sign (=) represent in JavaScript?

    <p>An assignment operator</p> Signup and view all the answers

    What does the isNaN() function return when applied to a variable that holds a numerical division by a string that cannot be converted to a number?

    <p>True, because the result is Not a Number</p> Signup and view all the answers

    What will be the result of comparing (new Number(500) == new Number(500))?

    <p>False, because they are different instances</p> Signup and view all the answers

    Where is the best place to break a long JavaScript statement?

    <p>After an operator</p> Signup and view all the answers

    What will happen when you use comments to prevent code execution?

    <p>The code will not be executed at all</p> Signup and view all the answers

    Which of the following accurately describes JavaScript variables?

    <p>They are containers for storing data values</p> Signup and view all the answers

    Which statement is NOT true about multi-line comments in JavaScript?

    <p>They can only contain alphanumeric characters</p> Signup and view all the answers

    When are local variables deleted in JavaScript?

    <p>When the function is completed</p> Signup and view all the answers

    What happens to global variables when the page is closed?

    <p>They are deleted when the page is closed</p> Signup and view all the answers

    Which object represents the global scope in an HTML document?

    <p>window</p> Signup and view all the answers

    Which of the following correctly exemplifies a JavaScript string?

    <p>var car = 'Toyota';</p> Signup and view all the answers

    What is an example of an HTML event that JavaScript can respond to?

    <p>An HTML input field being modified</p> Signup and view all the answers

    When using quotes inside a string, what rule should be followed?

    <p>Use different quote types for string and content</p> Signup and view all the answers

    How can JavaScript code be executed when an event occurs?

    <p>Using event handler attributes in HTML</p> Signup and view all the answers

    Which statement is true about function arguments in JavaScript?

    <p>They behave as local variables within the function</p> Signup and view all the answers

    What will be the value of 'txt3' after executing the following JavaScript code: var txt1 = 'John'; var txt2 = 'Doe'; var txt3 = txt1 + ' ' + txt2;

    <p>John Doe</p> Signup and view all the answers

    Which operator would you use to append a string to an existing variable in JavaScript?

    <p>+=</p> Signup and view all the answers

    What is the maximum number of accurate decimal digits that JavaScript can represent with floating-point arithmetic?

    <p>17 digits</p> Signup and view all the answers

    What is the correct way to define a function in JavaScript?

    <p>function name() { code to be executed }</p> Signup and view all the answers

    When a number exceeds the largest possible value in JavaScript, what value is returned?

    <p>Infinity</p> Signup and view all the answers

    What will be the output of the variable 'y' after executing the following code: var x = '5' + 5;

    <p>'55'</p> Signup and view all the answers

    How is a hexadecimal number represented in JavaScript?

    <p>By prefixing it with '0x'</p> Signup and view all the answers

    When is a JavaScript function invoked?

    <p>When an event occurs or is called from other code</p> Signup and view all the answers

    What will be the value of the variable 'carName' after the declaration 'var carName;'?

    <p>undefined</p> Signup and view all the answers

    What happens when a return statement is reached in a JavaScript function?

    <p>The function terminates and returns control</p> Signup and view all the answers

    Which of the following correctly demonstrates variable declaration and assignment in one statement?

    <p>var carName = 'Volvo';</p> Signup and view all the answers

    Which of the following statements about numbers in JavaScript is accurate?

    <p>JavaScript numbers are always stored as 64-bit floating-point numbers.</p> Signup and view all the answers

    What is the result of the operation 0.2 + 0.1 in JavaScript?

    <p>0.30000000000000004</p> Signup and view all the answers

    What does the variable 'anum' hold in the statement 'var anum = '3.14';'?

    <p>The string '3.14'</p> Signup and view all the answers

    In JavaScript, what type will the variable 'z' have after executing var z = 5 + '5';?

    <p>String</p> Signup and view all the answers

    What will the type of NaN evaluate to when using typeof in JavaScript?

    <p>number</p> Signup and view all the answers

    Which best describes the use of parameters in a JavaScript function?

    <p>They provide names used in the function definition.</p> Signup and view all the answers

    How can multiple variables be declared in a single statement?

    <p>Use var to declare all variables and separate them with commas.</p> Signup and view all the answers

    What happens if you re-declare a JavaScript variable?

    <p>The variable will retain its previous value.</p> Signup and view all the answers

    Which of the following operations will result in NaN?

    <p>Dividing 0 by 0</p> Signup and view all the answers

    What does the expression '123e5' represent in JavaScript?

    <p>12300000</p> Signup and view all the answers

    Which of the following is true about strings in JavaScript?

    <p>Strings must be enclosed in single or double quotes.</p> Signup and view all the answers

    What is the initial value of a variable declared with 'var varName;'?

    <p>undefined</p> Signup and view all the answers

    What is the effect of surrounding a number with quotes in JavaScript?

    <p>The number will be treated as a string.</p> Signup and view all the answers

    What method should be used to set the year in a JavaScript date object?

    <p>setFullYear()</p> Signup and view all the answers

    What does the Date.parse() method return?

    <p>The number of milliseconds since January 1, 1970</p> Signup and view all the answers

    Which comparison operator is used to check if one date object is later than another?

    <blockquote> </blockquote> Signup and view all the answers

    How can you access the first element in an array declared as var cars = ['Toyota', 'Honda', 'BMW'];?

    <p>cars[0]</p> Signup and view all the answers

    Which method allows you to set the hour of a date object in JavaScript?

    <p>setHours()</p> Signup and view all the answers

    What is the purpose of using arrays in JavaScript?

    <p>To hold multiple values under one variable name</p> Signup and view all the answers

    When using setDate() to add 4 days to the current date, what do you first retrieve?

    <p>The current date</p> Signup and view all the answers

    If you wanted to convert a string date into a date object, which approach could you use?

    <p>Date.parse(stringDate)</p> Signup and view all the answers

    What is the benefit of closing all HTML elements?

    <p>It makes the document readable by XML parsers.</p> Signup and view all the answers

    Which statement is true regarding HTML tags and case sensitivity?

    <p>HTML tags can be in either case but lowercase is preferred.</p> Signup and view all the answers

    What is a requirement for specifying attributes in HTML?

    <p>Attributes are specified in name/value pairs.</p> Signup and view all the answers

    Why is it important to declare a language in HTML?

    <p>It improves accessibility for screen readers.</p> Signup and view all the answers

    What does the 'href' attribute represent in an HTML link?

    <p>It indicates the location of the link destination.</p> Signup and view all the answers

    What do single or double quotes around attribute values provide?

    <p>They clarify the start and end of the attribute value.</p> Signup and view all the answers

    What is the recommended practice regarding HTML attribute names?

    <p>They should be written in lowercase for stricter validation.</p> Signup and view all the answers

    Which statement about the title attribute in HTML is correct?

    <p>It can provide additional context about the element.</p> Signup and view all the answers

    What does URL encoding do to unsafe ASCII characters?

    <p>It replaces them with a '%' followed by two hexadecimal digits.</p> Signup and view all the answers

    Which HTTP method is primarily used for submitting data to be processed?

    <p>POST</p> Signup and view all the answers

    What distinguishes HTTPS from HTTP?

    <p>HTTPS communications are encrypted and authenticated.</p> Signup and view all the answers

    What is the primary role of a web server?

    <p>To serve files that form web pages in response to client requests.</p> Signup and view all the answers

    Which statement accurately describes a web service?

    <p>It communicates using HTTP and typically resides on a web server.</p> Signup and view all the answers

    What is the purpose of a domain name?

    <p>To provide a unique identifier for a web server.</p> Signup and view all the answers

    In a client-server model, what does an application server do?

    <p>It provides components to create and run web applications.</p> Signup and view all the answers

    Which character is commonly used to replace spaces in URLs?

    <ul> <li>or %20</li> </ul> Signup and view all the answers

    Where is the best place to break a JavaScript statement that does not fit on one line?

    <p>After an operator</p> Signup and view all the answers

    What is the primary purpose of code blocks in JavaScript?

    <p>To group statements to be executed together</p> Signup and view all the answers

    Which of the following rules is NOT true for valid JavaScript identifiers?

    <p>Identifiers can begin with a digit</p> Signup and view all the answers

    What does adding '//' in front of a code line accomplish in JavaScript?

    <p>It prevents the line from being executed</p> Signup and view all the answers

    What represents the assignment operator in JavaScript?

    <p>=</p> Signup and view all the answers

    Why are comments useful in JavaScript code?

    <p>To explain the code and improve readability</p> Signup and view all the answers

    Which type of comment allows for multiple lines in JavaScript?

    <p>/* comment */</p> Signup and view all the answers

    Which statement about JavaScript variables is true?

    <p>They can store different data types</p> Signup and view all the answers

    Why are comments considered beneficial in HTML?

    <p>They help debug HTML by allowing you to comment out code.</p> Signup and view all the answers

    What is the purpose of the alt attribute in HTML?

    <p>To provide alternate text for an image if it is not displayed.</p> Signup and view all the answers

    In HTML, how can images be utilized as links?

    <p>By wrapping the image tag within an anchor tag.</p> Signup and view all the answers

    What will be the value of a variable that is declared but not initialized?

    <p>undefined</p> Signup and view all the answers

    When is it appropriate to use single quotes in HTML attributes?

    <p>When the attribute value itself contains double quotes.</p> Signup and view all the answers

    What are conditional comments used for in HTML?

    <p>To enable HTML comments in older browsers.</p> Signup and view all the answers

    Which of the following correctly declares multiple variables in one statement?

    <p>var person = 'John Doe', carName = 'Volvo', price;</p> Signup and view all the answers

    What data type is represented by the value '3.14' when written with quotes?

    <p>string</p> Signup and view all the answers

    What role do screen readers play in web accessibility?

    <p>They convert text-to-speech or braille output for users.</p> Signup and view all the answers

    When defining a hyperlink in HTML, which tag is crucial?

    <p>The <a> tag.</p> Signup and view all the answers

    Which statement is true about re-declaring a variable in JavaScript?

    <p>It keeps the existing value.</p> Signup and view all the answers

    What is the correct way to assign a value to a declared variable, carName?

    <p>var carName = 'Volvo';</p> Signup and view all the answers

    What is a potential disadvantage of leaving HTML comments in production code?

    <p>They can slow down the loading time of the web page.</p> Signup and view all the answers

    When a number is treated as a string due to quotes, what will happen in an arithmetic operation?

    <p>It will concatenate the number with the string.</p> Signup and view all the answers

    Which keyword is used to declare a variable in JavaScript?

    <p>var</p> Signup and view all the answers

    What will be the output of 'console.log(carName)' if carName was declared but not initialized?

    <p>undefined</p> Signup and view all the answers

    What character is used in JavaScript to avoid confusion with special characters in strings?

    <p>Backslash (\</p> Signup and view all the answers

    When splitting a long line of code for better readability, where is it best to break the line?

    <p>After an operator</p> Signup and view all the answers

    How can a string that contains both single and double quotes be correctly represented in JavaScript?

    <p>Use escape characters for both types of quotes</p> Signup and view all the answers

    What will the length of the string 'We are the so-called "Vikings" from the north.' be in JavaScript?

    <p>45</p> Signup and view all the answers

    Which statement is accurate regarding the representation of special characters in strings?

    <p>They need to be preceded by a backslash</p> Signup and view all the answers

    What does the Top Level Domain (TLD) in a domain name identify?

    <p>The main category of an organization's website</p> Signup and view all the answers

    What is the primary function of the File Transfer Protocol (FTP)?

    <p>To transfer files between computers over a network</p> Signup and view all the answers

    What role does an FTP client serve in file transfer?

    <p>It sends and retrieves files using FTP protocol</p> Signup and view all the answers

    Which of the following statements about HTML is accurate?

    <p>HTML is the standard markup language for creating web pages.</p> Signup and view all the answers

    Which statement correctly describes the role of semicolons in JavaScript?

    <p>Semicolons separate statements and are required at the end of each executable statement.</p> Signup and view all the answers

    What is the purpose of having a domain name mapped to an IP address?

    <p>To facilitate easy recall of website addresses for users</p> Signup and view all the answers

    Which part of a domain name is considered the Third Level Domain or Sub Domain?

    <p>www in <a href="http://www.google.com">www.google.com</a></p> Signup and view all the answers

    What happens when multiple spaces are used in JavaScript code?

    <p>JavaScript simply ignores multiple spaces for readability.</p> Signup and view all the answers

    What does the acronym ICANN represent in the context of domain name registration?

    <p>Internet Corporation for Assigned Names and Numbers</p> Signup and view all the answers

    Which of these statements about JavaScript identifiers is true?

    <p>Identifiers are case sensitive and can differ by letter case.</p> Signup and view all the answers

    Which example demonstrates proper camel case variable naming?

    <p>firstName</p> Signup and view all the answers

    Which of the following is NOT a component of a domain name?

    <p>Local Area Network</p> Signup and view all the answers

    What is the primary purpose of a JavaScript statement?

    <p>To execute a command for the browser.</p> Signup and view all the answers

    How is the Unicode character set relevant to JavaScript?

    <p>It covers all characters, punctuation, and symbols available in the language.</p> Signup and view all the answers

    Which method can be used to improve the readability of a JavaScript script?

    <p>By using Camel Case naming convention.</p> Signup and view all the answers

    What is the recommended maximum line length for JavaScript code to ensure best readability?

    <p>80 characters</p> Signup and view all the answers

    What is the result of using the === operator to compare a primitive string and a String object in JavaScript?

    <p>They are considered not equal.</p> Signup and view all the answers

    Which method is typically considered safest for breaking up a long string in JavaScript?

    <p>String addition.</p> Signup and view all the answers

    How does JavaScript treat primitive values when executing methods and properties?

    <p>It temporarily converts them into objects.</p> Signup and view all the answers

    In JavaScript, which statement correctly describes the execution of a code line that attempts to break up using a backslash?

    <p>It generates a syntax error.</p> Signup and view all the answers

    What will the type of variable 'y' be after executing var y = new String('Mike');?

    <p>object</p> Signup and view all the answers

    Which of the following accurately describes primitive strings in JavaScript?

    <p>They are immutable <code>oncetime</code> types.</p> Signup and view all the answers

    When comparing two strings in JavaScript using the == operator, what is important?

    <p>The equality of the string values matters.</p> Signup and view all the answers

    Which of the following statements is true regarding string literals and String objects in JavaScript?

    <p>String objects can be used where literals cannot.</p> Signup and view all the answers

    What happens when you perform an operation that exceeds the maximum representable number in JavaScript?

    <p>The result is Infinity.</p> Signup and view all the answers

    Which of the following represents a number in scientific notation correctly?

    <p>All of the above</p> Signup and view all the answers

    Which statement accurately describes how JavaScript handles numbers?

    <p>JavaScript uses double precision floating point numbers for all numeric values.</p> Signup and view all the answers

    What is the maximum accuracy for integers in JavaScript without losing precision?

    <p>15 digits</p> Signup and view all the answers

    What value will be stored in 'y' after executing 'var y = 9999999999999999;'?

    <p>10000000000000000</p> Signup and view all the answers

    What does 'NaN' stand for in JavaScript?

    <p>Not an Number</p> Signup and view all the answers

    What will the result be when adding 0.2 and 0.1 in JavaScript?

    <p>0.30000000000000004</p> Signup and view all the answers

    How does JavaScript interpret numeric constants prefixed with '0x'?

    <p>As hexadecimal numbers</p> Signup and view all the answers

    What does HTML stand for?

    <p>Hyper Text Markup Language</p> Signup and view all the answers

    Who is responsible for making Web standards?

    <p>The World Wide Web Consortium</p> Signup and view all the answers

    Which character is used to indicate an end tag in HTML?

    <p>/</p> Signup and view all the answers

    Which attribute specifies alternate text for an image in HTML?

    <p>alt</p> Signup and view all the answers

    Which HTML element is used to create a hyperlink?

    <a> Signup and view all the answers

    How can you open a link in a new tab or window in HTML?

    <p>Using the target='_blank' attribute</p> Signup and view all the answers

    What is the correct HTML for inserting an image?

    <img src='image.gif'> Signup and view all the answers

    Which HTML element defines the title of a document?

    &lt;title> Signup and view all the answers

    What is the correct way to express the Boolean expression p↔q using only ¬, ∧, and ∨?

    <p>(p ∧ q) ∨ (¬p ∧ ¬q)</p> Signup and view all the answers

    What is the negation of the statement ∀x∃y ( P( x) ∧ ¬Q( y ) )?

    <p>∃x∀y (¬P(x) ∨ Q(y))</p> Signup and view all the answers

    What distinguishes a subset from a proper subset?

    <p>A proper subset cannot be equal to the original set.</p> Signup and view all the answers

    Why must a function be both 1-to-1 and onto to be considered invertible?

    <p>To ensure that each output maps to one and only one input.</p> Signup and view all the answers

    What is the cardinality of the power set of a set containing n elements?

    <p>$2^n$</p> Signup and view all the answers

    For a uniqueness proof, which two properties must be demonstrated?

    <p>Existence and Uniqueness.</p> Signup and view all the answers

    Which method involves proving a statement by showing that its negation leads to a contradiction?

    <p>Proof by contradiction</p> Signup and view all the answers

    What is one key characteristic of a vacuous proof?

    <p>It proves the statement by providing no exceptions.</p> Signup and view all the answers

    What is the relationship between a statement p and its converse q?

    <p>The converse of p is q.</p> Signup and view all the answers

    Which law states that p ∨ T ≡ T?

    <p>Domination Law</p> Signup and view all the answers

    Which of the following is the result of applying Simplification?

    <p>p ∧ q becomes p.</p> Signup and view all the answers

    What does the Absorption Law state?

    <p>p ∨ (p ∧ q) is equivalent to p.</p> Signup and view all the answers

    Which inference rule is used to conclude ¬p given [¬q ∧ (p → q)]?

    <p>Modus Tollens</p> Signup and view all the answers

    In set theory, what is the result of A ∩ (B ∪ C)?

    <p>(A ∩ B) ∪ (A ∩ C)</p> Signup and view all the answers

    What does the Tautology Rule state when given p?

    <p>p leads to p ∨ q.</p> Signup and view all the answers

    Which Boolean logic rule allows you to conclude p ∧ ¬p leads to F?

    <p>Complementation</p> Signup and view all the answers

    What is the result of applying pure logical reasoning to p ∨ ¬p?

    <p>It is always true.</p> Signup and view all the answers

    What is the outcome of applying Conjunction on two propositions p and q?

    <p>Both must be true for p ∧ q to be true.</p> Signup and view all the answers

    Which law identifies that p ∨ F is equivalent to p?

    <p>Identity Law</p> Signup and view all the answers

    What is the principle behind the Hypothetical Syllogism?

    <p>It links two implications.</p> Signup and view all the answers

    What is the outcome of applying Modus Ponens on p → q and p?

    <p>It confirms that q is true.</p> Signup and view all the answers

    What does A ∅ represent in set theory?

    <p>The intersection of A with the empty set.</p> Signup and view all the answers

    What does the TLD in a domain name stand for?

    <p>Top Level Domain</p> Signup and view all the answers

    What is the primary function of the File Transfer Protocol (FTP)?

    <p>To transfer files over a network</p> Signup and view all the answers

    Which component of the domain name identifies the specific organization?

    <p>Second Level Domain</p> Signup and view all the answers

    Which of the following languages is NOT considered a cornerstone technology for web page creation?

    <p>Python</p> Signup and view all the answers

    How does an FTP client typically relay information to a server?

    <p>By sending data packets</p> Signup and view all the answers

    What does HTML stand for?

    <p>Hyper Text Markup Language</p> Signup and view all the answers

    What is represented by the domain name 'www.example.com'?

    <p>A readable format of an IP address</p> Signup and view all the answers

    Which of the following is a characteristic of a subdomain?

    <p>It identifies a specific section of a website</p> Signup and view all the answers

    When should single quotes be used in HTML attributes?

    <p>When the attribute value contains double quotes</p> Signup and view all the answers

    What is the main purpose of HTML comments?

    <p>To aid in debugging and documenting the code</p> Signup and view all the answers

    What functionality does the id attribute provide in HTML?

    <p>It assigns a unique identifier for bookmarks within a document</p> Signup and view all the answers

    What is the role of the alt attribute in HTML?

    <p>To specify alternative text when the image cannot be displayed</p> Signup and view all the answers

    How can HTML comments assist during debugging?

    <p>By allowing the developer to hide lines of code temporarily</p> Signup and view all the answers

    What do screen readers do with HTML content?

    <p>They reproduce HTML as text-to-speech or braille output</p> Signup and view all the answers

    Why should software program tags be left inside HTML comments?

    <p>To maintain compatibility with original software that generated them</p> Signup and view all the answers

    What is the expected use of the style attribute in HTML images?

    <p>To specify the width and height of an image</p> Signup and view all the answers

    What will the value of the variable x be after executing var x = 100 / 'Apple';?

    <p>NaN</p> Signup and view all the answers

    Which statement is true when using the == equality operator with numbers and Number objects?

    <p>They compare value only and not type.</p> Signup and view all the answers

    When using the === operator, what will be the result of (var x = 500; var y = new Number(500); x === y)?

    <p>false</p> Signup and view all the answers

    What will happen if you try to compare two Number objects with the == operator?

    <p>They cannot be compared and will return false.</p> Signup and view all the answers

    Which of the following methods converts a number into a string representation?

    <p>toString()</p> Signup and view all the answers

    What does the method toExponential() do to a number in JavaScript?

    <p>Returns a string in exponential notation.</p> Signup and view all the answers

    What property do primitive numbers lack in JavaScript?

    <p>They can hold methods.</p> Signup and view all the answers

    Why does JavaScript treat primitive values as objects when executing methods and properties?

    <p>To provide flexibility in handling data types.</p> Signup and view all the answers

    What occurs when a variable is declared without an initial value in JavaScript?

    <p>It defaults to a value of 'undefined'.</p> Signup and view all the answers

    Which statement accurately represents how you can declare multiple variables in JavaScript?

    <p>You can declare many variables using a single var statement separated by commas.</p> Signup and view all the answers

    How does JavaScript treat a number when it is enclosed in quotation marks?

    <p>It treats it as a text string.</p> Signup and view all the answers

    What will be the value of the variable 'carName' after its declaration if no value is assigned?

    <p>It will have the value 'undefined'.</p> Signup and view all the answers

    Which of the following is correct regarding the assignment of values to variables in JavaScript?

    <p>You can assign a new value at any time after declaration.</p> Signup and view all the answers

    Which of the following correctly states the nature of JavaScript strings?

    <p>Strings must be enclosed in quotes, either single or double.</p> Signup and view all the answers

    What happens if a variable is not initialized with a value in JavaScript and is accessed later?

    <p>It will return 'undefined'.</p> Signup and view all the answers

    What keyword is used to declare a variable in JavaScript?

    <p>var</p> Signup and view all the answers

    What will happen to the 'fruits' array after executing the line 'fruits = "Kiwi"'?

    <p>The array will consist only of 'Kiwi'.</p> Signup and view all the answers

    What will the 'fruits' array look like after executing 'fruits.splice(2, 1, "Lemon", "Kiwi")'?

    <p>[&quot;Banana&quot;, &quot;Orange&quot;, &quot;Lemon&quot;, &quot;Kiwi&quot;, &quot;Mango&quot;]</p> Signup and view all the answers

    What is the result of calling 'fruits.sort()' on an array of fruits?

    <p>The elements will be sorted alphabetically.</p> Signup and view all the answers

    What will be the output of 'fruits.reverse()' after sorting the array?

    <p>[&quot;Orange&quot;, &quot;Mango&quot;, &quot;Banana&quot;, &quot;Apple&quot;]</p> Signup and view all the answers

    How does the compare function affect the sorting of an array?

    <p>It sets a specific sorting order based on the return value.</p> Signup and view all the answers

    What does using 'delete fruits' do to the 'fruits' array?

    <p>It sets the first element to undefined.</p> Signup and view all the answers

    After executing 'fruits[fruits.length] = "Kiwi"', which of the following represents the contents of 'fruits'?

    <p>[&quot;Banana&quot;, &quot;Orange&quot;, &quot;Apple&quot;, &quot;Mango&quot;, &quot;Kiwi&quot;]</p> Signup and view all the answers

    How can the 'sort()' method affect the order of numbers in an array?

    <p>It sorts numbers based on their string representation.</p> Signup and view all the answers

    Study Notes

    JavaScript Functions

    • Functions are blocks of code designed to perform specific tasks.
    • Function invocation (calling) triggers execution.
    • Function definitions use the function keyword followed by a name and parentheses.
    • Parameters are names listed in the function definition.
    • Arguments are real values received when the function is invoked.
    • Functions can be invoked by events like user clicks, from JavaScript code, or automatically (self-invoked).
    • return statements stop function execution and return a value to the invoking statement.

    JavaScript Scope

    • Scope refers to the accessible variables, objects, and functions within a particular part of a program.
    • JavaScript uses function scope, meaning scope changes within functions.
    • Local variables are declared within a function and are only accessible within that function.
    • Global variables are declared outside functions and are accessible to all scripts and functions on a page.
    • Undeclared variables assigned a value automatically become global variables.

    JavaScript Operators

    • Operators are used for arithmetic and comparisons.
    • The assignment operator (=) assigns a value to a variable.
    • The addition operator (+) adds numbers and concatenates strings.
    • The += operator adds to existing values.

    JavaScript Strings

    • Strings can be primitive values or objects.
    • Primitive strings are created from literals using double quotes ("").
    • String objects are created using the new String() constructor.
    • The == operator checks for equality of string values.
    • The === operator checks for equality of both type and value.

    JavaScript Numbers

    • Numbers can be written with or without decimals.
    • Scientific notation (exponent notation) is used for very large or small numbers.
    • JavaScript numbers are always 64-bit floating-point numbers.
    • Integers are accurate up to 15 digits.
    • Floating-point arithmetic may not be perfectly accurate.
    • Hexadecimal numbers are preceded by 0x.
    • Infinity is returned for calculations exceeding the maximum number or division by zero.
    • NaN (Not a Number) indicates invalid number calculations.

    JavaScript Arrays

    • Arrays are ordered lists of values.
    • Elements are accessed using numeric indexes starting from 0.
    • Arrays can contain various data types.
    • Length property indicates the number of elements in the array.
    • Arrays are used to store collections of related data.
    • Use [] brackets to create arrays, avoiding the new Array() constructor.

    JavaScript Objects

    • Objects are collections of key-value pairs.
    • Keys are strings (names) while values can be any data type.
    • Objects are useful for grouping related data under meaningful names.
    • Use curly braces ({}) to create objects.
    • Methods are functions associated with objects.
    • Objects are not ordered collections.

    Displaying Dates

    • The script document.getElementById("demo").innerHTML = Date(); displays the current date and time inside an HTML element with the id "demo".

    JavaScript Date Object

    • The Date object is used to work with dates and times.
    • A date consists of a year, month, day, hour, minute, second, and milliseconds.
    • Date objects are created with the new Date() constructor.
    • new Date(): Creates a new date object representing the current date and time.
    • new Date(milliseconds): Creates a new date object representing the given number of milliseconds since January 1, 1970, 00:00:00 UTC.
    • new Date(dateString): Creates a new date object from a date string.
    • new Date(year, month, day, hours, minutes, seconds, milliseconds): Creates a new date object with the specified date and time, using 7 numerical arguments.

    Date Methods

    • Date methods allow you to get and set the year, month, day, hour, minute, second, and millisecond of date objects.
    • The toString() method converts a date object to a string representation.
    • The toUTCString() method converts a date object to a UTC string.

    JavaScript Operators

    • The = operator assigns a value to a variable.
    • The + operator can be used to add numbers or concatenate strings.
    • The += operator is used to add (concatenate) strings and assign the result to the original variable.

    Adding Strings and Numbers

    • Adding two numbers results in the sum.
    • Adding a number and a string results in a concatenated string.

    JavaScript Functions

    • A function is a block of code designed to perform a specific task.
    • Functions are invoked (called) to execute the code they contain.
    • Functions are defined with the function keyword, followed by the function name, parentheses, and curly braces.
    • Function parameters are variables listed in the function definition.
    • Function arguments are the actual values passed to the function during invocation.

    Why Functions?

    • Functions allow you to reuse code.
    • Comments within functions are ignored and not executed.

    JavaScript Case Sensitivity

    • JavaScript is case sensitive, meaning lastName and lastname are different variables.

    JavaScript and Camel Case

    • Camel case is a common naming convention for variables in JavaScript.
    • Camel case starts with a lowercase letter and capitalizes the first letter of subsequent words, for example, firstName and masterCard.

    JavaScript Character Set

    • JavaScript uses the Unicode character set, which covers most characters, punctuations, and symbols from various languages.

    JavaScript Statements

    • Statements tell the browser what to do.
    • Statements are executed sequentially, unless modified by control flow structures.
    • Statements are separated by semicolons (;).

    JavaScript White Space

    • JavaScript ignores multiple spaces between elements.
    • Whitespace can be used for readability.

    JavaScript Line Length and Line Breaks

    • Long JavaScript statements can be broken across multiple lines.
    • It's best to break lines after operators.

    JavaScript Code Blocks

    • Statements can be grouped within code blocks enclosed in curly braces {...}.
    • Code blocks define statements to be executed together.

    JavaScript Comments

    • Comments are used to explain code and improve readability.
    • Comments are ignored by JavaScript.
    • Single-line comments start with //.
    • Multi-line comments start with /* and end with */.

    JavaScript Variables

    • Variables are containers for storing data values.
    • Variable names are unique identifiers, using a combination of letters, digits, underscores (_), and dollar signs ($).
    • Variable names must start with a letter, _, or $.
    • Variable names are case-sensitive.

    JavaScript Assignment Operator

    • The = operator assigns a value to a variable.
    • It is not an "equal to" operator in the mathematical sense.

    JavaScript Numbers

    • Numbers can be primitive values or objects.
    • Primitive numbers are created from literals, for example, var x = 123.
    • Number objects are created using the new Number() constructor.

    Equality Operators for Numbers

    • == operator checks for equality in value only.
    • === operator checks for equality in value and type.
    • Objects cannot be compared using equality operators.

    Number Properties and Methods

    • Primitive values don't have properties and methods.
    • However, JavaScript treats primitive values as objects when executing methods and properties temporarily.

    JavaScript Variable Lifetime

    • The lifetime of a JavaScript variable starts when it is declared.
    • Local variables are deleted when the function they are defined in is complete.
    • Global variables are deleted when the browser window or tab they are defined in is closed.
    • Function arguments (parameters) act as local variables within functions.
    • Global variables are stored in the window object.

    JavaScript Events

    • JavaScript interacts with HTML using events.
    • Events are actions that occur in the browser or user interactions with the page.
    • Common events include:
    • Page loading
    • Changes in input field values
    • Clicking a button
    • You can write JavaScript code that executes when a specific event occurs.
    • Event Handlers are attributes in HTML elements that allow JavaScript code to be executed when an event occurs.
    • Example: <button onclick="myFunction()">Click me</button>
    • The onclick attribute calls the myFunction() when the button is clicked.

    JavaScript Strings

    • JavaScript strings store sequences of characters enclosed in quotes.
    • You can use single or double quotes to define a string.
    • Example: "Mike Slough" or 'Mike Slough'
    • You can embed quotes within strings as long as they don't match the surrounding quotes.
    • Example: "This string has 'single' quotes inside"

    JavaScript Operators

    • JavaScript operators allow you to perform mathematical operations on variables.
    • Common operators include:
    • =: assignment operator, assigns a value to a variable.
    • +: addition operator, adds two values.
    • Example:
    • var x = 5 + 2 + 3;
    • var x = 5; // assigns the value 5 to x
    • var y = 2; // assigns the value 2 to y
    • var z = x + y; // assigns the value 7 to z (x + y)

    JavaScript String Operators

    • The + operator can concatenate (join) strings.
    • Example:
    • txt1 = "John";
    • txt2 = "Doe";
    • txt3 = txt1 + " " + txt2; // txt3 becomes "John Doe"
    • The += operator can also be used to concatenate strings.
    • Example:
    • txt1 = "What a very ";
    • txt1 += "nice day"; // txt1 becomes "What a very nice day"

    Adding Strings and Numbers

    • Adding two numbers results in their sum.
    • Adding a number and a string results in a string concatenation.
    • Example:
    • x = 5 + 5; // x becomes 10
    • y = "5" + 5; // y becomes "55"
    • z = "Hello" + 5; // z becomes "Hello5"

    JavaScript Functions

    • A JavaScript function is a block of code that performs a specific task.
    • Functions are executed when called or invoked.
    • Syntax:
      function functionName(parameter1, parameter2, parameter3) {
        // code to be executed
      }
      
    • Parameters are the names listed in the function definition.
    • Arguments are the actual values passed to the function when it is called.
    • Function invocation can be triggered by:
    • Events (like user clicks)
    • Calls from other JavaScript code
    • Self-invocation (automatically running)
    • Return statement: When a return statement is encountered within a function, the function stops executing and returns a value to the caller.
    • Importance of Functions:
    • Code reusability: Define a function once and use it multiple times.

    JavaScript Data Types

    • JavaScript variables can hold different types of data.
    • Two main data types:
    • Numbers: Like 100
    • Strings: Text values like "John Doe"
    • Strings are written within double or single quotes.
    • Example: "John Doe" or 'John Doe'
    • Numbers are written without quotes.
    • Example: 100
    • If a number is enclosed within quotes, JavaScript treats it as a string.

    Declaring JavaScript Variables

    • Declaring a variable in JavaScript is called "declaring" it.
    • You use the var keyword to declare a variable.
    • Example:
    • var carName;
    • Initially, a declared variable has no value (it's undefined).
    • You assign a value to a variable using the equals sign (=).
    • Example:
    • carName = "Volvo";
    • You can declare multiple variables in one statement by separating them with commas.
    • Example:
    • var person = "John Doe", carName = "Volvo", price = 200;
    • If you re-declare a variable, it doesn't lose its existing value.
    • Example:
    • var x = 34.00; // A number with decimals
    • var x = 34; // x remains 34.00

    JavaScript Number Types

    • JavaScript uses 64-bit floating-point numbers for all numeric values.
    • Numbers are stored using the IEEE 754 standard.
    • The format stores the number (fraction), exponent, and sign in separate bits:
    • Value (Fraction/Mantissa): 52 bits
    • Exponent: 11 bits
    • Sign: 1 bit
    • Precision:
    • Integers are accurate up to 15 digits.
    • Maximum decimal places: 17
    • Floating-point operations may have slight inaccuracies.

    JavaScript Hexadecimal Numbers

    • JavaScript interprets a numeric constant as hexadecimal if it starts with 0x.
    • Example: var x = 0xFF; // x will be 255

    JavaScript Infinity

    • Infinity is a special number that represents a value larger than the largest possible number.
    • It can be generated by dividing by zero or by performing operations that result in a value outside the maximum number range.
    • Example:
    • var x = 2 / 0; // x will be Infinity
    • var y = -2 / 0; // y will be -Infinity
    • typeof Infinity returns "number".

    JavaScript NaN (Not a Number)

    • NaN (Not a Number) is a special value indicating that a value is not a valid number.

    JavaScript Dates

    • JavaScript Date objects represent points in time.
    • Use new Date() to create a new Date object.
    • Use Date.parse() to convert a string to a date object.
    • Use methods like setDate(), setFullYear(), setHours(), setMilliseconds() to modify date components.
    • Use methods like getDate(), getFullYear(), getHours(), getMilliseconds() to get date components.
    • Example:
    • var d = new Date(); // d becomes the current date
    • d.setDate(d.getDate() + 4); // Adds 4 days to d
    • Compare dates using comparison operators like >, <, ===.

    JavaScript Arrays

    • Arrays are variables that can hold multiple values.
    • Each value in an array is accessed by its index, starting from 0.
    • Example:
    • var cars = ["Toyota", "Honda", "BMW"];
    • cars[0] // returns "Toyota"

    JavaScript Array Methods

    • push(): Adds new elements to the end of an array.
    • pop(): Removes the last element of an array and returns it.
    • unshift(): Adds new elements to the beginning of an array.
    • shift(): Removes the first element of an array and returns it.
    • slice(): Extracts a portion of an array and returns a new array.
    • splice(): Adds or removes elements from an array at a specified index.
    • concat(): Combines two or more arrays and returns a new array.
    • join(): Converts an array into a string with a specified separator between elements.
    • reverse(): Reverses the elements of an array.
    • sort(): Sorts elements of an array in ascending order.
    • forEach(): Executes a provided function for each element in the array.
    • indexOf(): Returns the index of the first occurrence of a specified element in the array.

    URL Encoding

    • URLs cannot contain spaces.
    • Spaces are replaced with a plus (+) sign or %20

    HTTP

    • Hypertext Transfer Protocol
    • Application level protocol
    • Request-response protocol between client and server over the web
    • Foundation of data communication for the World Wide Web

    HTTP Requests

    • GET requests data from a specified resource:
      • Has a limited length
      • Can be cached by the client
    • POST submits data to be processed to a specified resource:
      • Has no data limit
      • Never cached

    HTTPS

    • Hypertext Transfer Protocol Secure
    • HTTP over SSL
    • All communications between client and server are encrypted and authenticated

    Web Server

    • A program that uses HTTP to serve files that form web pages
    • Responds to user requests from HTTP clients
    • Can also refer to dedicated computers or appliances

    Application Server

    • Software framework that provides facilities to create web applications
    • Provides a server environment to run web applications
    • Acts as a set of components accessible to the developer through an API

    Web Services

    • Client and server applications that communicate over the WWW using HTTP
    • Typically reside on a web server
    • Use XML to communicate messages

    Web Agents / User Agents

    • Software applications used by users to communicate with a web server
    • Retrieve resources or receive data
    • Web browsers are the most common example

    Domain

    • A unique name for your website

    HTML Elements

    • HTML5 does not require empty elements to be closed, but it's recommended for strict validation or XML parser readability.
    • HTML tags are not case sensitive.

    HTML Attributes

    • Provide additional information about an element
    • Specified in the start tag
    • Name/value pairs

    The lang Attribute

    • Declares the document language in the <html> tag
    • Important for accessibility applications and search engines

    The title Attribute

    • Provides a title for HTML elements
    • Example: <p title="paragraph">

    The href Attribute

    • Defines links in HTML documents
    • Specifies the link address in the href attribute
    • Example: <a href="https://www.google.com">Visit Google!</a>

    Size Attributes

    • Used with the <img> tag to define the width and height of an image
    • Example: <img src="image.jpg" width="100" height="100">

    Attribute Names

    • HTML5 doesn't require lowercase attribute names, but it's recommended

    Attribute Values

    • HTML5 doesn't require quotes around attribute values, but it's recommended
    • Double quotes are most common, but single quotes can be used

    HTML Comments

    • Not displayed by the browser
    • Used for documentation, notifications, and reminders
    • Example: <!-- This is a comment -->
    • Useful for debugging by commenting out code
    • Can be generated by HTML software programs like FrontPage and Expression Web
    • Hyperlinks, text or images you can click on to jump to another document
    • Defined with the <a> tag
    • Example: <a href="https://www.google.com">Visit Google!</a>
    • Images can be used as links within HTML
    • Example: <a href="https://www.google.com"><img src="image.jpg" alt="Google Logo"></a>

    The id Attribute

    • Used to create bookmarks inside HTML documents
    • Bookmarks are invisible to the reader
    • Example: <p id="tips">Useful Tips Section</p>

    The alt Attribute

    • Specifies an alternate text for an image if it cannot be displayed
    • Describes the image in words
    • Important for screen readers

    Screen Readers

    • Software programs that read what is displayed on a screen
    • Convert HTML to text-to-speech, sound icons, or braille output
    • Used by people with visual impairments

    JavaScript Code Formatting

    • If a JavaScript statement doesn't fit on one line, break it after an operator
    • Example: document.getElementById("demo").innerHTML = "Hello Dolly.";

    JavaScript Code Blocks

    • Statements grouped together inside curly brackets {...}
    • Define statements to be executed together

    JavaScript Comments

    • Explain and make code more readable
    • Prevent execution during testing
    • Single line comments: Start with //
    • Multi-line comments: Start with /* and end with */

    JavaScript Variables

    • Containers for storing data values
    • Example: var x = 5;

    JavaScript Identifiers

    • Unique names used to identify variables
    • Can contain letters, digits, underscores, _, and dollar signs, $
    • Must begin with a letter or $ or _
    • Case sensitive (y and Y are different variables)
    • Reserved words like JavaScript keywords cannot be used

    The Assignment Operator

    • The equal sign = is an assignment operator, not an "equal to" operator
    • Assigns a value to a variable

    JavaScript Data Types

    • JavaScript variables can hold different types of data:
      • Numbers : Example: var pi = 3.14;
      • Strings: Text values enclosed in double or single quotes. Example: var person = "John Doe";
    • If you put quotes around a number, it will be treated as a text string

    Declaring (Creating) JavaScript Variables

    • Use the var keyword
    • Example: var carName;
    • Assign a value using the equal sign =
    • Example: carName = "Volvo";

    Multiple Variable Declaration

    • Declare multiple variables in one statement separated by commas
    • Example: var person = "John Doe", carName = "Volvo", price = 200;

    Variable Value: undefined

    • Variables declared without a value have the value undefined
    • The value can be calculated or provided later

    Re-Declaring Variables

    • Re-declaring a JavaScript variable does not lose its value

    Domain Names

    • A domain name is a part of a URL that tells a domain name server (DNS) where to forward a request for a web page.
    • Domain names are mapped to IP addresses, representing physical points on the internet.
    • Domain names consist of three parts:
      • Top Level Domain (TLD): .pk, .com, .gov
      • Second Level Domain: Must be unique on the internet and registered with an ICANN-accredited registrar
      • Third Level Domain (Sub Domain): www, validate
      • Example: www.google.com.pk
        • TLD: .pk
        • Second Level Domain: google
        • Third Level Domain: www

    Internet Hosting

    • Allows organizations and individuals to serve content on the internet.

    File Transfer Protocol (FTP)

    • Standard network protocol used to transfer files between hosts over a TCP-based network.
    • FTP is simple and secure.
    • Files are split into small data packets.
    • Client sends a packet to the destination after opening an authenticated connection.
    • FTP server checks the packet and sends a request for the next packet until the entire file is received.

    FTP Client

    • Software used to communicate with an FTP server to transfer files using the FTP protocol.

    HTML (Hyper Text Markup Language)

    • Standard markup language used to create web pages.
    • Used alongside CSS and JavaScript.
    • Web browsers read HTML files and render them as visible or audible web pages.

    JavaScript

    • Case Sensitivity: JavaScript identifiers are case sensitive (lastName and lastname are different variables).
    • Camel Case: A convention for naming variables with multiple words.
      • Starts with a lowercase letter, followed by capitalized words (firstName, masterCard).
    • JavaScript Character Set: Uses the Unicode character set, covering most characters, punctuation, and symbols.

    JavaScript Statements

    • Instructions that tell the browser what to do.
    • Executed one by one, in the order they are written.
    • Separated by semicolons (;).
    • White Space: Ignored by JavaScript.
    • Line Length and Line Breaks: Programmers often avoid code lines longer than 80 characters. Lines can be broken after operators or using string addition.

    Strings

    • Strings must be written within quotes (' or ").
    • Use the backslash escape character () to represent special characters like ' or " inside a string.
    • String Length: Found in the built-in property "length".
    • String as Objects: Can be defined as objects using the "new" keyword.

    Numbers

    • Can be written with or without decimals.
    • Scientific Notation: Used for very large or very small numbers (e.g., 123e5).
    • JavaScript Numbers as 64-bit Floating Point: Numbers are stored as double precision floating point numbers, following the IEEE 754 standard.
    • Precision: Integers are accurate up to 15 digits. Floating point arithmetic can be imprecise.
    • Hexadecimal: Numeric constants preceded by 0x are interpreted as hexadecimal (e.g., 0xFF).
    • Infinity: Returned when a number is outside the largest possible number.
    • NaN (Not a Number): Indicates that a value is not a number.

    What does HTML stand for?

    • HTML stands for Hyper Text Markup Language.

    Who is making the Web standards?

    • The World Wide Web Consortium (W3C) makes web standards.

    Largest Heading

    • The <h1> tag is the largest heading in HTML.

    Line Break

    • The <br> tag is used to insert a line break.

    Background Color

    • The bgcolor attribute is used to add a background color.

    Important & Emphasized Text

    • The <strong> tag defines important text
    • The <em> tag defines emphasized text.
    • The <a> tag is used to create a hyperlink.
    • The href attribute specifies the URL of the link.
    • The target attribute specifies where to open the link (e.g., "_blank" for a new tab/window).

    Ending Tags

    • The / character is used to indicate an end tag.

    HTML Elements

    • <h1>, <h2>, <h3>, <h4>, <h5>, <h6> are all heading elements.

    Numbered List

    • The <ol> tag is used to create a numbered list.
    • The <li> tag defines each list item

    Bulleted List

    • The <ul> tag is used to create a bulleted list.
    • The <li> tag defines each list item.

    Checkbox

    • The <input type="checkbox"> tag is used to make a checkbox.

    Text Input Field

    • The <input type="text"> tag is used to make a text input field.
    • The <select> tag is used to make a drop-down list.
    • The <option> tag defines each option in the list
    • The value attribute defines the value associated with each option.

    Text Area

    • The <textarea> tag is used to make a text area.

    Image Insertion

    • The <img> tag is used to insert an image.
    • The src attribute specifies the URL of the image.
    • The alt attribute specifies alternative text for the image, if the image cannot be displayed.

    Background Image

    • The background attribute in the <body> tag is used to insert a background image.

    Title of Document

    • The <title> tag defines the title of a document.

    Alternate Text for Images

    • The alt attribute is used to specify alternate text for an image.

    HTML5 Doctype

    • The <!DOCTYPE html> doctype is correct for HTML5.
    • The <footer> tag is used to specify a footer for a document or section.

    Video and Audio Files

    • The <video> tag is used to play video files
    • The <audio> tag is used to play audio files.

    Midterm 1: CS 202, Spring 2005

    • Logic section covers 33 points
    • Structures section covers 16 points
    • Proofs section covers 51 points
    • Exam has 100 points in total and lasts 75 minutes
    • Part I covers logical equivalences, logic operators, and quantifiers
    • Part II covers set theory, function composition, and cardinality
    • Part III covers types of proofs, including direct, indirect, and proof by contradiction
    • Question 1: asks for the converse of a conditional statement p→q
    • Question 2: asks for an equivalent compound proposition using ¬, ∧, and ∨
    • Question 3: asks for the negation of a quantified statement
    • Question 4: asks for the two ways to convert a propositional function into a proposition
    • Question 5: asks for a proof using logic equivalences
    • Question 6: asks for the difference between subset and proper subset
    • Question 7: asks about 1-to-1 and onto properties required for invertibility
    • Question 8: asks for the cardinality of the power set of a set with n elements
    • Question 9: asks for the composition of two functions f and g
    • Question 10: asks for the two core properties needed for proving uniqueness
    • Question 11: asks for writing the existential generalization of a quantified statement
    • Question 12: asks for the difference between vacuous and trivial proofs
    • Question 13: asks for the specific movie previewed in class
    • Question 14: asks for a proof that if m is even, then m+7 is odd. Students can choose from two methods: direct proof, indirect proof, or proof by contradiction
    • Question 15: is about statement implication and proof by contradiction

    Domain Name

    • A part of a Uniform Resource Locator (URL) that identifies a specific website on the internet
    • It's used by the Domain Name System (DNS) to find the corresponding IP address of the website
    • Examples include google.com, facebook.com, validate.ecp.gov

    Domain Name Structure

    • Top Level Domain (TLD): The final part of the domain name (e.g., .com, .org, .gov)
    • Second Level Domain: Unique and registered with an ICANN-accredited registrar (e.g., google, facebook, validate)
    • Third Level Domain (Sub Domain): A subdomain of the second-level domain (e.g., www, mail)

    Hosting

    • A service for organizations and individuals to make their web content accessible on the internet
    • They provide servers and related technology to run websites.

    File Transfer Protocol (FTP)

    • A protocol used to transfer files between computers over a network (like the internet)
    • It splits files into packets and transfers them after authentication
    • FTP clients are software used to communicate with FTP servers

    Hyper Text Markup Language (HTML)

    • The standard language for creating web pages
    • Used alongside CSS and JavaScript for building websites and user interfaces
    • Web browsers interpret HTML files to render them into visible web pages.
    • Hyperlinks are text or images that link to other documents.
    • They are defined with the <a> tag in HTML.
    • Syntax: <a href="link_address">Link text</a>

    HTML Images

    • Image links are defined with the <img> tag in HTML.
    • They are defined with the <img> tag in HTML.
    • Syntax: <img src="image_address" alt="alternative_text_for_image">

    HTML Bookmarks

    • Bookmarks are created using the id attribute in HTML.
    • They are not displayed on the page and are used for linking to specific sections of the page.
    • Example: <h1 id="tips">Useful Tips Section</h1>

    The alt Attribute in HTML Images

    • Provides alternative text for images that cannot be displayed.
    • It describes the image in words for screen readers and users with visual impairments.

    Screen Readers

    • Software programs that convert the contents of a screen into different forms (e.g., text-to-speech, braille output)
    • Help people who are blind, visually impaired, or have learning disabilities access web content.

    Image Size

    • The width and height attributes (or the style attribute) can be used to resize images.

    JavaScript Data Types

    • Variables can hold different types of data:
      • Numbers: Represent numerical values (e.g., 100, 3.14)
      • Strings: Represent text values and are enclosed in quotes (e.g., "John Doe", "Hello world!")
      • Undefined: Represents a variable that has not been assigned a value yet.

    Declaring JavaScript Variables

    • var keyword: Used to declare a variable.
    • Assignment operator (=): Used to assign a value to a variable.
    • Example: var carName = "Volvo";

    JavaScript Arrays

    • Ordered collections of data.
    • Use square brackets ([]) to create arrays.
    • Example: var fruits = ["Banana", "Orange", "Apple", "Mango"];

    Modifying Array Elements

    • Access by index: Use the index to access specific array elements.
    • Example: console.log(fruits[0]); // Outputs "Banana"

    Adding Elements to Arrays

    • Appending at end: Use array.length to add elements to the end of the array.
    • Example: fruits[fruits.length] = "Kiwi"; // Pushes "Kiwi" to the end

    Deleting Array Elements

    • delete operator: Remove elements from an array and sets them to undefined.
    • Example: delete fruits[0];

    Splicing Arrays

    • The splice() method adds new elements to an array.
    • Example: fruits.splice(2, 1, "Lemon", "Kiwi"); // Inserts "Lemon" and "Kiwi" at index 2, removing one existing element.

    Sorting Arrays

    • The sort() method sorts an array alphabetically.
    • Example: fruits.sort();

    Reversing Arrays

    • The reverse() method reverses the elements in an array.
    • Example: fruits.reverse();

    Compare Function for Sorting Arrays

    • The sort() method accepts a compare function to define a custom sort order.
    • The compare function should return a negative, zero, or positive value based on the comparison.
    • Example: points.sort(function(a, b){return a-b}); // Sorts in ascending order.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Midterm Paper CS202 PDF
    CS202 Mid Term Past Paper PDF

    Description

    Explore the concepts of functions and scope in JavaScript. This quiz covers function definitions, invocation, parameters, arguments, and the difference between local and global variables. Test your knowledge on how scope affects variable accessibility within your programs.

    More Like This

    JavaScript Functions Quiz
    5 questions

    JavaScript Functions Quiz

    EnviableHeliotrope7209 avatar
    EnviableHeliotrope7209
    Basic JavaScript Functions Quiz
    6 questions

    Basic JavaScript Functions Quiz

    SustainableAntigorite1088 avatar
    SustainableAntigorite1088
    Overview of Functions in JavaScript
    10 questions
    Use Quizgecko on...
    Browser
    Browser