0 ratings0% found this document useful (0 votes) 46 views26 pagesUnit I - Basics of JavaScript Programming - ForStudents
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Basies of JavaScript Programming Unit-1 Basics of JavaScript Programming Q. What is JavaScript? a) JavaScript is an object-based scripting language. b) JavaScript makes a web page more interactive. ©) Itallows you to implement dynamic features on web pages. 4) JavaScript can update and change both HTML and CSS. e) JavaScript can calculate, manipulate and validate data. 1.1 Features of JavaScrip' Q. List features of Java script. Answer: 1) JavaScript is an object-based scripting language. 2). Giving the user more control over the browser. 3) It Handling dates and time. 4) Itdetecting the user's browser and OS. 5) Itis light weighted. 6) Client-Side Technology. 7) JavaScript is a scripting language and it is not java 8) JavaScript is interpreter based scripting language. 9) JavaScript is case sensitive 10) JavaScript is object based language as it provides predefined objects. 11) Every statement in JavaScript must be terminated with semicolon, 12) Most of the JavaScript control statements syntax is same as syntax of control statements in C language. 13)An important part of JavaScript is the ability to create new fun Declare a function in JavaScript using function keyword. ions within scripts. Q. Explain features of Java script. 1) Client-Side Technology: JavaScript is a client-side technology. It is mainly used for giving client-side validation. It is an object-based scripting language. 2) Greater Control: It gives the user more control over the browser. Example — You can change the background color of the page as well as text on the browser's status bar. Here, the back button is implemented with JavaScript. Click it and you will return to the page from which you have arrived. 3) Detecting the User’s Browser and OS: The feature to detect the users browser and OS enables your script to perform platform-dependent operations. 4) Browser support: To access flash content, you need to install a flash plugin in your browser. But to use JavaScript, you don't have to use any plu; browsers have accepted JavaScript as a scripting language for them and provide integrated support for it. All you need to do is to handle some of the tasks that are in at all. This is because allBasies of JavaScript Programming dependent on the DOM (Document Object Model) of different browsers properly. 5) Performing Simple Calculation on the Client side: Using a JavaScript calculator, we perform simple calculations on the client side. 6) Validating The User’s Input: In the JavaScript calculator, try to type some lette ad of numeric input, you will get an error: Invalid input character. Note that JavaScript helps the brows server access. If the user makes a mistake in the input, the user will get an error message immediately. If the input information is validated only on the server, then the user would have to wait for the server's response. 7) Handling Date and time: The Date object is a built-in object in JavaScript that stores the date and time. It provides a number of built-in methods for formatting and managing that data. + perform output validation without wasting the user’s time by the web 1.2 Object Name, Property, method, Dot Syntax, Main event Object Name: 1) JavaScript is an object based scripting language. 2) It allows us to define our own objects and make our own variable types. 3) It also offers a set of predefined objects. 4) The tables, forms, buttons, images, or links on our web page are examples of objects. 5) The values associated with objects are properties and the actions that can perform on objects are methods or behavior. 6) Property associated to an object can be accessed as follows: Example for object and property using dot (.) Syntax: ObjectName.PropertyName Example: documentaitle; In the above example “document” is an object name accessing property of document “title” with “.” (Dot syntax) Property: 1) Properties are the values associated with a JavaScript object. 2). A JavaScript object is a collection of properties. 3) Properties can usually be changed, added, and deleted, but some are read only. 4) List of Some of the common properties of the document object are: a) Title - returns/ sets the title of the current document. ) Forms - retums a list of the FORM elements within the current document. ) Images - returns a list of the images in the current document 4) URL- returns a string containing the URL of the current document €) Location - to load another URL in the current document window. Syntax: ObjectName.PropertyName Example: document.title; In the above example “document” is an obj “(Dot syntax) name accessing property of document “title” withBasies of JavaScript Programming Dot Syntax: 1) For accessing properties and methods of an object we can use dot (.) operator. Syntax: ‘ObjectName.PropertyName or ObjectName.MethodName ‘Example: document.title: or document.write); In the above example “document” is an object name accessing property “title” and method “write” with “.” dot operator. Method: 1) Method is a function or a process associated with each object, 2) JavaScript methods are actions that can be performed on objects. 3) List of some methods and its purposes: a) open() - Opens a document for writing b) write() - Writes string/data to a document ©) writeln() - Writes string/data followed by a newline character to a document 4) close() - Closes a document stream for writing. ‘Syntax: ObjectName.MethodName Example: document.write(); My Page Titles/title>