In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "javascript how to find the area of graphics", the content of the explanation is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "javascript how to find the area of graphics"!
Javascript method for calculating the area of a graph: [function Circle (r) {if (this instanceof Circle) {this.r=r; this.area=function () {return Math.PI*this].
This article operating environment: windows10 system, javascript 1.8.5, thinkpad T480 computer.
Figure area solution:
The first kind: constructor
Document function Retangle (this instanceof Retangle b) {if (this instanceof Retangle) {this.a=a; this.b=b; this.area=function () {return this.a*this.b; / / console.log (Math.PI*this.r*this.r) } this.premeter=function () {return (this.a+this.b) * 2; / / console.log (Math.PI*this.r*2);}} else {return new Retangle (amemb);}} let c=new Retangle (10mem10) / / console.log (c instanceof Circle); / / judge Bool value console.log (c.area ()); console.log (c.premeter ()); Retangle (10Ling 10)
Area of the circle:
Document function Circle (r) {if (this instanceof Circle) {this.r=r; this.area=function () {return Math.PI*this.r*this.r;} this.premeter=function () {return Math.PI*this.r*2 }} else {return new Circle (r);}} let c=new Circle (10); / / console.log (c instanceof Circle); console.log (c.area ()); console.log (c.premeter ()); Circle (10)
There are two forms of output:
Windows- ordinary function
Circle (10); console.log (window.r); console.log (window.area ()); console.log (window.premter ())
Constructor function
Let c = new Circle (10); / / console.log (c); console.log (c instanceof Circle); console.log (c.r); console.log (c.area ()); console.log (c.premter ())
The second kind:
Title function Retangle () {var a = document.getElementById ("A1"). Value; var b = document.getElementById ("b1"). Value; alert ("rectangular area:" + aqb);} length:
Width:
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.