Article

Introduction

https://cdn.jsdelivr.net/npm/[email protected]/dist/js.cookie.min.js
Copy to clipboard

An object is a way to store a wide variety of related information in a structured manner.

The structure can be depicted as {attribute : value}. Where attribute is the name given to some value we want to refer to.

We can define an object as follows: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/objects/ex1.js?actionable=true

In the above example name and age are attributes of the object. John and 20 is the data associated with the respective attributes.

We can store a variety of data types in objects attributes. These data types include: strings, numbers, other objects and functions.

Functions that are defined within objects are often refereed to as methods. Methods allow a developer to modify attributes of an object.

In addition to defining our own custom objects, the browser provides some useful inbuilt objects.

One object that is frequently encountered in web development is the document object.

It contains information of the web page and some functions used to describe the current state of the web page.

document.readyState contains info about the loading status of the document.

document.title holds the title of the web page. We can show this title by executing this code: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/objects/ex2.js?actionable=true document.write() is a method commonly used to add text to a page. If we want to add arbitrary text such as “hello world” to a web page then we use the following code: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/objects/ex3.js?actionable=true write() is a function or object method that lets you modify the object which in this case, is document.Object literals are a way of quickly storing a wide variety of related information in an object like format: https://raw.githubusercontent.com/finsweet/jqueryCourse/main/objects/ex4.js?actionable=true

<script>
$(document).ready(function(){
  XT1
});
</script>
Copy to clipboard
Send to Live Demo

Live demo

<div id="minidivpage" class="example-live"><div id="resultdiv"></div></div>

<script>    
$(document).ready(function() {
  XT1
});
</script>
<script>
  
</script>
Copy to clipboard
Press the Run Demo button to execute the scripts above.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Your browser is too small

Resize your browser to be at least 769px wide.