Posts

Showing posts from December, 2023

9. Window and Cookies in Javascript

   Window Object in JavaScript: The window object is a global object in the browser's JavaScript environment.  It represents the browser window or frame and provides various properties and methods for interacting with it. Properties of the window Object: 1. window.innerWidth and window.innerHeight:    - Return the inner width and height of the browser window. 2. window.outerWidth` and `window.outerHeight:    - Return the outer width and height of the browser window including toolbars and scrollbars. 3. window.location:    - Provides information about the current URL and allows navigation to other URLs. 4. window.document:    - Represents the DOM (Document Object Model) of the current page. 5. window.navigator:    - Provides information about the browser and its capabilities. 6. window.localStorage and window.sessionStorage:    - Allow storage of key-value pairs persistently or for the duration of the page session...

8. DOM and Event

Image
  Document Object Model (DOM) - Every web page resides inside a browser window which can be considered as an object. - A Document object represents the HTML document that is displayed in that window. The Document object has various properties that refer to other objects which allow access to and modification of document content. - The way a document content is accessed and modified is called the Document Object Model, or DOM. The Objects are   organized in a hierarchy. This hierarchical structure applies to the organization of objects in a Web document. DOM tree - The backbone of an HTML document is tags. - According to the Document Object Model (DOM), every HTML tag is an object. Nested tags are “children” of the enclosing one. The text inside a tag is an object as well. - Every tree node is an object. - All these objects are accessible using JavaScript, and we can use them to modify the page. - Everything in HTML, even comments, becomes a part of the DOM.   ...

7. Function in JavaScript

  Function in JavaScript A function in JavaScript is a block of code that contains a group of instructions to perform a particular task. Syntax : Function nameOfFunction(parameters-list) { // Lines of code to be executed to perform a specific task. } Types of Functions in JavaScript There are two types of functions in JavaScript like any other programming language such as C, C++, and Java. 1.Predefined functions 2.User-defined functions 1.Predefined Functions in JavaScript 1. alert(): This function displays an alert dialog box on the browser. 2. confirm(): This function displays a confirmation dialog box and asks the user to choose one from two options. 3. prompt(): The prompt() function displays a prompt dialog box on the browser and prompts the user to enter input. 4. write(): The write() function used to write something on the document. 5. Date(): This function used to get the current date and time. 6. select(): The select() function used to select the pointed object. 7. parse...

6. Object and Array in Javascript

  Object in Javascript - An object in JavaScript is an entity or any real-world thing that has a state and behavior. - Here, the state represents properties (characteristics) of an object and behavior represents actions or functionality of an object. - For example, a person is an object. He has properties like black hair, black eyes, fair skin, weight, etc., and actions like eat, sleep, walk, play, study, etc. Object Creation in JavaScript - JavaScript is template based, not class based. Here, we don’t create class to get the object. But, we direct create objects. 1. By object literal 2. By creating an instance of Object directly (using new keyword) 3. Using an object constructor (using new keyword) 1. By object literal - The simplest and the most popular way to create an object in JavaScript is to use object literal. - we create objects with curly braces and  separate properties and values  by using colon (:). Ex :  var objectName = {     propertyName1:val...

5. String and Math Object in JavaScript

  String in JavaScript  - A string in JavaScript is a sequence of Unicode characters. It is simply an array of characters. Each character takes 16 bits. - Each character in the string has its position or index.  Ex : let name1 = "John"; // Double quotes let name2 = 'Bob'; // Single quotes. String Object in JavaScript - String is an object. Any variable whose value is a string is actually a string object. That is, JavaScript stores a string value as a string object in a variable. - The string object in JavaScript is a wrapper around the string primitive value. It is the most commonly used object in JavaScript. String Creation  Ways to create String in JavaScript There are two ways to create string in JavaScript. They are as follows: 1. By string literal  Ex : let stringname="string value"; 2. By string object (using new keyword and String() constructor) Ex : let str = new String("Hello JavaScript"); - We can also using character array    Note:   - ...

3. Operator in Javascript

Image
Operators in JavaScript - Operators in JavaScript are very similar to the operators that appear in the other programming languages, such as C++, or Java. - Operators are used extensively in JavaScript program to perform some sort of calculation, comparison, or assignment on one or more values. Operator Sub-types in JavaScript There are three sub-types of operators in JavaScript. They are: 1. Unary : Unary operator is an operator that takes only a single operand. 2. Binary : Binary operator is an operator that takes two operands. 3. Ternary : Ternary operator is an operator that takes three operands. Precedence of Arithmetic Operators in JavaScript There are two priority levels of arithmetic operation in JavaScript. They are as follows: High priority: * / % Low priority: + – If two or more sets of parentheses occur into the expression one after another, the order of evaluation will be done from the left set towards the right set. Types of Operators in JavaScript In JavaScript programmin...

1. Introduction of Javascript

Image
  Introduction of JS JavaScript: JavaScript (originally known as LiveScript) is cross-platform, object-based scripting language that was developed by Netscape programmer Brendan Eich for both client side and server side. It is a lightweight programming language that is interpreted by web browser when the web page is loaded. JavaScript is the most popular language and almost easy to learn as HTML. Features of JavaScript Language (JS) 1. JavaScript (JS) is a high-level, interpreted, cross-platform, and open-source programming language. 2. JavaScript (js) is a lightweight object-based scripting programming language that is mainly used in web programming. 3. It supports both client-side and server-side scripting. 4. It is responsible for making web pages interactive and responsive. Like HTML defines the content and structure of web page, CSS styles the layout, and JavaScript make that web page interactive. 5. JS is not a compiled language, but it is an interpreted language. The JavaScr...

Windows in JavaScript

Understanding Windows in JavaScript Introduction: In JavaScript, the window object plays a crucial role in the browser environment. It represents the browser window or frame and serves as the global object for JavaScript code running within a browser. Properties of the Window Object: 1. Document Object: window.document: Represents the HTML document loaded in the window. It provides methods and properties to interact with the document's content. 2. Location Object: window.location: Contains information about the current URL, allowing you to manipulate or retrieve details like protocol, hostname, pathname, and more. 3. Navigator Object: window.navigator: Provides information about the browser, such as its name, version, and platform. Useful for determining the user's environment. 4. Screen Object: window.screen: Represents the user's screen, providing details like width, height, color depth, etc. 5. History Object: window.history: Allows interaction with the browser's ses...