Introduction
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
$(document).ready(function(){
XT1
});
</script>
Live demo
<div id="minidivpage" class="example-live"><div id="resultdiv"></div></div>
$(document).ready(function() {
XT1
});
</script>