JS-Part 5: What is Object in JavaScript? How to create an Object in JavaScript?

Опубликовано: 05 Октябрь 2024
на канале: Codenbox AutomationLab
136
6

#JavaScript #ObjectInJavascript #CreateObject
+Object in JavaScript
+What is Object in JavaScript?
+How to create an Object in JavaScript?
+How to access properties in an Object?
=======================================
-Object is a non-primitive data type in JS.
-JS objects are like containers or variables what hold properties or methods or both.
-Object properties are written as key: value pairs, separated by commas. a key is a string (also called a “property name”), and value can be anything.
As we know It can have function as a property or member which is known as a method of that object.

The object literal is a simple way of creating an object using { } brackets. You can include key-value pair in { }, where key would be property or method name and value will be value of property of any data type or a function. Use comma (,) to separate multiple key-value pairs.
Syntax: var (object-name)={key1:value1, key2: value2,...};
Example: //object with multiple properties
var person = {
firstName: "John",
lastName: "Doe",
age:50} ;

Here: The object in the example above has 3 properties: firstName, lastName, age and values are :john, Doe, 50

======================================================
~~~Subscribe to this channel, and press bell icon to get all updated videos on Selenium and Cypress Automation:
   / codenboxautomationlab  

~~~ Follow us on Facebook & Twitter to get more updates:
  / codenboxqa  
  / codenboxteam