With statement usage instance in Javascript
- 2020-06-12 08:29:46
- OfStack
This article illustrates the use of With statements in Javascript. Share to everybody for everybody reference. The details are as follows:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>With statements ( Similar to the VB In the )</title>
<script type="text/javascript">
function Student(name, age) {
this.name = name;
this.age = age;
}
var stu = new Student(' ronaldo ', 36);
with (stu) {
//With statements ( Similar to the VB In the ), Used to simplify code
alert("Name:" + name + ",Age:" + age);
}
</script>
</head>
<body>
</body>
</html>
Hopefully, this article has been helpful in your javascript programming.