Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the idea of js object-oriented programming

Shulou Source: shulou.com Published: 2022-06-03 15:22:16 10月02日 Update

What is js object-oriented programming idea, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

With the advent of technologies like Node.js, you can now write JavaScript code on the server side, and you can even use JavaScript to query persistent data stores like MongoDB.

one

two

/ / @ arrange (512. Notes) www.512pic.com

Var bill = {}

The above code is not very useful, it just creates an empty object. Let's dynamically add some properties and methods to this object.

one

two

three

four

five

/ / @ arrange (512. Notes) www.512pic.com

Bill.name = "Bill E Goat"

Bill.sound = function () {

Console.log ('bahhhwa')

}

Here we add the "name" attribute and assign it to "Bill E Goat". We don't have to create empty objects in front of us, but we can do all of the above in one step.

one

two

three

four

/ / @ arrange (512. Notes) www.512pic.com

Var bill = {

Name: "Bill E Goat", sound: function () {console.log ('bahhhwa');}

}

It's simple and beautiful, isn't it? Accessing properties and methods is just as simple.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Objects properties notes code methods help ideas programming clarity beauty simplicity content dynamic just for this technology persistence data articles novice Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Apple Microsoft macOS Linux