filmov
tv
41. Javascript Objects - Full stack web development Course

Показать описание
In this #FullStackWebDevelopment tutorial series video, We are going to learn about basics of #javascripts #objects, how can we work with them to compact our code and make it reusable.
JavaScript object is a collection of named values. These objects are quite different from JavaScript’s primitive data-types(Number, String, Boolean, null, undefined and symbol) in the sense that while these primitive data-types all store a single value each (depending on their types).
Objects are more complex and each object may contain any combination of these primitive data-types as well as reference data-types. Loosely speaking, objects in JavaScript may be defined as an unordered collection of related data, of primitive or reference types, in the form of “key: value” pairs. These keys can be variables or functions and are called properties and methods, respectively, in the context of an object.
An object can be created with figure brackets {…} with an optional list of properties. A property is a “key: value” pair, where a key is a string (also called a “property name”), and value can be anything.
For example:
var student1 = {
name : "Boris Johnson",
rollNo. : "07",
DOB : "19-06-1964"
display: function() {
};
In the above example “name”, “Roll no.”, “DOB” are all keys which are the property of the object “student” and “Boris Johnson”, “07” and “19-06-1964”(which are all string type) are values of these keys respectively. We separate keys and values of an object with a comma. We can also create a function inside of an object. Here the key is “display” and function() is the value. this keyword is used to refer to the property of the specified object. If we are inside of a function and want to refer to other properties inside of an object we use this keyword.
There are two other ways we can work with objects:
A) Creating new empty object: var student1 = {};
student1.DOB : "19-06-1964";
B) Object Constructor: It creates an object wrapper for the given value. This, used in conjunction with the “new” keyword allows us to initialize new objects.
Example:
var student1 = new object();
student1.DOB : "19-06-1964";
----------------------------
Week 1 : Day 7
Section 5 : Learning to Code With Javascript
Tutorial 41: Javascript Objects
----------------------------
Do subscribe and hit Bell Icon
----------------------------
Follow us in social media handles for opportunities and code related support.
----------------------------
Got a question on the topic? Please share it in the comment section below and our experts will answer it for you.
JavaScript object is a collection of named values. These objects are quite different from JavaScript’s primitive data-types(Number, String, Boolean, null, undefined and symbol) in the sense that while these primitive data-types all store a single value each (depending on their types).
Objects are more complex and each object may contain any combination of these primitive data-types as well as reference data-types. Loosely speaking, objects in JavaScript may be defined as an unordered collection of related data, of primitive or reference types, in the form of “key: value” pairs. These keys can be variables or functions and are called properties and methods, respectively, in the context of an object.
An object can be created with figure brackets {…} with an optional list of properties. A property is a “key: value” pair, where a key is a string (also called a “property name”), and value can be anything.
For example:
var student1 = {
name : "Boris Johnson",
rollNo. : "07",
DOB : "19-06-1964"
display: function() {
};
In the above example “name”, “Roll no.”, “DOB” are all keys which are the property of the object “student” and “Boris Johnson”, “07” and “19-06-1964”(which are all string type) are values of these keys respectively. We separate keys and values of an object with a comma. We can also create a function inside of an object. Here the key is “display” and function() is the value. this keyword is used to refer to the property of the specified object. If we are inside of a function and want to refer to other properties inside of an object we use this keyword.
There are two other ways we can work with objects:
A) Creating new empty object: var student1 = {};
student1.DOB : "19-06-1964";
B) Object Constructor: It creates an object wrapper for the given value. This, used in conjunction with the “new” keyword allows us to initialize new objects.
Example:
var student1 = new object();
student1.DOB : "19-06-1964";
----------------------------
Week 1 : Day 7
Section 5 : Learning to Code With Javascript
Tutorial 41: Javascript Objects
----------------------------
Do subscribe and hit Bell Icon
----------------------------
Follow us in social media handles for opportunities and code related support.
----------------------------
Got a question on the topic? Please share it in the comment section below and our experts will answer it for you.
Комментарии