const p = document.getElementById("p1") – p ga p1 class berilgan p ni js dan boshqarish
const button = document.querySelector("#click");bu ham bir xil faqat buttonga id berilgan
P.InnerHTML = <“Span class=’qwer’”>qwertt - jsdan turib htmldagi p ni ozgartirish
p.textContent = “dwwfwef” --- faqat textni o’zini ozgartirish
p.className = “ “ --p ga class berish
let person = {
person .nomi = - -nuqta yangi nom qoyish uchun ishlatiladi.(person-umumiy) }
Person[‘nomi’]= bu nomi aniq bo’lmaganda ishlatiladi bu ham person ichida bo’ladi
funksiyani chaqirish uchun ishlatiladi
FUNKSIYALAR
function nomi(fristName,lastName) {
console.log('Assalom alykum, '+ fristName + lastName); }
nomi('Ahmat' , 'Abdullayev');
nomi('Hamid');
function square(number) {
return number*number; } -- 2 ni kvatratini hisoblash
console.log(square(2));
MATEMATIK FUNKSIYALAR
math.PI – pi soni
math.round(6.7) – butun songa aylantiradi
math.floor(5.1) – butun qismini oladi
math.pow (2,3) – 2 ni 3 chi darajasi
math.random() – 0 va 1 orasida ixtiyoriy qiymat qabul qiladi
BARCHASI STRING(so’zlar) TURI UCHUN
let nom = 'Assalom alaykum';
console.log(nom[3]); -- 4-harfni chiaradi
console.log(nom.includes('al')); -- nom dagi al harfi izlanadi agar bolsa true chiqaradi
console.log(nom.startsWith('Assolom')); -- shu sozdan boshlanganligini aniqlaydi
console.log(nom.indexOf('kum')); -- so’z nechinchi nomerdan boshlanganligi
console.log(nom.toUpperCase()); -- barcha xarflarni katta xarf aylantiradi
console.log(nom.toLowerCase()); -- barcha xarflarni kichik xarflarga aylantiradi
console.log(nom.trim()); -- boshi va oxiridagi probellarni olib tashlaydi
console.log(nom.replace('salom' , 'xayr')); -- salom sozini xayr soziga almashtirib beradi
console.log(nom.split(' ')); sozlarni bolib tashlaydi probel bor joylarni ajratadi
TO’PLAMLAMLAR UCHUN
numbers.push(5,6); -- toplam oxiriga yangi element qo’shish
numbers.unshift(1); -- toplam boshiga yangi element qo’shish
numbers.splice(x, y, z); -- (x)-nechinchi nomerdan (y)-nechta ochirish (z)-yangi element qo’shish
numbers.pop(); -- toplam oxiridagi elementni o’chiradi
numbers.shift();--toplam boshidagi elementni o’chiradi
numbers.splice(x,y); -- (x) –nechinchi nomerdan (y)- nechtasini ochirish
console.log(numbers.indexOf(3)); -- 3-nomerdagi index nomeri
console.log(numbers.includes(4)); -- 4 sonini izlanadi bo’lsa true
console.log(numbers);
let theree = frist.concat(two); -- to’plamlarni birlashtirish
console.log(theree);
let fo = theree.slice(x,y); -- to’plamlarni ajratish (x) dan (y) gacha ajratib oladi
console.log(fo);
let five = theree.join("-"); -- to’plamlarni birlashtiradi stringga aylantiradi – bilan ajratib chiqadi
console.log(five);
let numbers = [2,3,5,1,4];
numbers.sort(); -- toplamni tartiblaydi (1,2,3,4,5)
console.log(numbers);
let numbers = [2,3,5,1,4];
numbers.reverse(); -- toplamlarni teskari tartiblaydi (5,4,3,2,1)
console.log(numbers);
let numbers = [2,3,-5,1,4];
let isAllPositive = numbers.every(function(number) { -- birortasi shartni qanotlantirmasa false qaytaradi.
return number>=0; });
console.log(isAllPositive);
let numbers2 = [2,3,-5,1,4];
let atLeadOnePositive = numbers2.some(function(number){ -- aqalli birortasi shart qanotlantirsa true qaytaradi.
return number>=0; });
console.log(atLeadOnePositive);
let filtered = numbers.filter(function(number){ -- shartni qanotlantiruvchilarni alohida to’plamga ajratib beradi.
return number>=0; });
console.log(filtered);
Do'stlaringiz bilan baham: |