7 Javascript Fundamentals

Web Technology I · Unit 7

JavaScript Fundamentals

Exam-focused notes for JavaScript Fundamentals (Web Technology I, BIT251): what the TU syllabus asks and how it has actually been tested, with 4 solved past questions from this unit.

What this unit covers

  • JavaScript variable declaration and definition
  • JavaScript data types and values
  • JavaScript arrays definition and usage
  • JavaScript user defined objects
  • JavaScript functions and methods
  • Prompt and alert dialog boxes
  • String concatenation and manipulation

JavaScript variable declaration and definition

20795 marks

How variables in JavaScript are defined and declared? Write a JavaScript function that will include the variable having values number 5 and character '5' and print the variables. [5]

JavaScript provides three keywords to declare variables: Keyword Scope Re-declarable Re-assignable Notes ----------------------------------------------------- var Function/Global Yes Yes Old way, hoisted let Block No Yes Modern, preferred const Block No No ...

Full solved answer →

JavaScript user defined objects

2080.25 marks

Create a user-defined object Student in JavaScript. The object should have attributes with values as Name= "Ram", Age=20,DOB=2003/02/03 respectively. Now display the result retrieving the attributes. [5]

--- --- Step Description ------------------- Object Creation A user-defined object Student is created using object literal notation { } Attributes Name, Age, and DOB are the properties (attributes) of the object with their respective values Dot Notation Stu...

Full solved answer →

Prompt and alert dialog boxes

2080.25 marks

Write JavaScript program that will take your name as input using prompt and display the name using alert in alert box. [5]

--- Statement Description ------------------------ prompt("...") Displays a dialog box that takes input from the user and returns it as a string var name = prompt(...) Stores the entered name into the variable name alert("Hello, " + name) Displays the name ...

Full solved answer →

JavaScript arrays definition and usage

05 marks

How array is defined in JavaScript? Illustrate with example. [5]

An array in JavaScript is a special type of object used to store multiple values in a single variable. Arrays are ordered collections of data where each element is accessed by its index (starting from 0). JavaScript arrays are dynamic (can grow or shrink in...

Full solved answer →