GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

No menu could be recovered. Follow the blue links in the page.

This view

  • Original page
  • New address

GeezerVison is showing uz.javascript.info — Massivni nusxalash va saralash

  • Qo'llanma
  • JavaScript dasturlash tili
  • Ma'lumot turlari
  • Massiv usullari
darsga qaytish

Massivni nusxalash va saralash

Bizda arr massivi mavjud. Biz uning tartiblangan nusxasini olishni xohlaymiz, ammo arr ni o’zgartirmasdan.

Bunday nusxani qaytaradigan copySorted(arr) funktsiyasini yarating.

let arr = ["HTML", "JavaScript", "CSS"];

let sorted = copySorted(arr);

alert(sorted); // CSS, HTML, JavaScript
alert(arr); // HTML, JavaScript, CSS (hech qanday o'zgarish yo'q)

Nusxasini olish va undagi tartibni bajarish uchun slice() dan foydalanishimiz mumkin:

function copySorted(arr) {
  return arr.slice().sort();
}

let arr = ["HTML", "JavaScript", "CSS"];

let sorted = copySorted(arr);

alert( sorted );
alert( arr );
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.