This article mainly introduces the method that JavaScript uses function to define object and call, example analyzes function definition in JavaScript and relevant skill of using object and method, need friend can refer to
The examples in this article describe the methods that JavaScript uses function to define objects and invoke. Share to everyone for your reference. The specific analysis is as follows:
JS in the way you can define the object, the following JS code defines a movie function object, and then through the new method to declare the object, the call is very simple.
?
1 2 3 4 5 6 7 8 |
<script type= "Text/javascript" > Function Movie (title, director) {this.title = title; this.director = Director;} VA R aliens = new Movie ("Aliens", "Cameron"); document.write ("Aliens:" +aliens.tostring ()); </script> |
Output results
?
I hope this article will help you with your JavaScript programming.