The most viewed posts

About Desktop Icons in Windows Computer

How to clean up Windows Computer

Driver Booster

CCleaner

Advanced System Care

Myanmar font and keyboard for Windows

Registry Reviver

How to make a computer secure and run faster

some (JavaScript Array Method)

Terms and Conditions

The most viewed items

Desktop Hard Disk

HP ProBook 430

Dell Inspiron 5559

External Hard Disk

SONY Playstation Portable

Laptop RAM

Laptop

ZilaStar ICT Feb 25 2020, 09:47:07
Category : JavaScript Tutorials

JavaScript Array Properties

length
Sets or returns the number of elements in an array.

prototype
Allows you to add new properties and methods to an Array object.


//length
/*
const countries = ["USA", "UK", "Canada", "Myanmar", "Singapore"];

function showLength(){
document.getElementById("demo").innerHTML = countries.length;
}

//prototype

Array.prototype.tnwCase = function(){
for(let i = 0; i < this.length; i++){
this[i] = this[i].toLowerCase(); //lower case
}
};

const countries = ["USA", "UK", "Canada", "Myanmar", "Singapore"];
countries.tnwCase();

function tnwFun(){
document.getElementById("demo").innerHTML = countries;
}*/

//Another example of prototype property

function Person(first, middle, last){
this.firstName = first;
this.middleName = middle;
this.lastName = last;
}

const myFriend = new Person("Aung", "Kyaw", "Soe");
Person.prototype.nationality = "Myanmar";
Person.prototype.age = 35;

function tnwFun(){
document.getElementById("demo").innerHTML = myFriend.age;
}

  • Comments:

    No comment to show.

    To Contact
    Available Services
    Terms and Conditions