شرح صفوف ومحتوى الفقرة
Example
HTML
<script>
class Test
{
static display()
{
return "static method is invoked"
}
}
document.writeln(Test.display());
</script>
Example
نستطيع تنفيذ اكثر من دالة من النوع static دون حدون اي مشاكل كما في المثال التالي
HTML
<script>
class Test
{
static display1()
{
return "static method is invoked"
}
static display2()
{
return "static method is invoked again"
}
}
document.writeln(Test.display1()+"<br>");
document.writeln(Test.display2());
</script>
في المثال التالي نقوم خلاله بتنفيذ اكثر من دالة من النوع static بأسماء متشابها ونجد ان لغة الجافا سكريب تتجاهلهم وتعتمد اخر دالة تم انشائها فقط
HTML
<script>
class Test
{
static display()
{
return "static method is invoked"
}
static display()
{
return "static method is invoked again"
}
}
document.writeln(Test.display());
</script>