Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the idea of js object-oriented programming

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report