Front end darsliklari moduli html, css, javascript


Download 105.45 Kb.
bet7/12
Sana15.02.2023
Hajmi105.45 Kb.
#1200512
1   2   3   4   5   6   7   8   9   ...   12
Bog'liq
FRONT END full notes (7) (2022 05 08 17 42 47 UTC)

2. JAVASCRIPT – Data types
• Math ( .round, .pow, .sqrt, .abs, .ceil, .floor, .min, .max, .random)
• condition operation ( ==, ===, >,<, >=,, && , ++, --) farqlari solishtirish…
• exercise…
parseInt(binary, 2) —> binary to int
Number(42).toString(2); //101010 —> int to binary

3. JAVASCRIPT – String
• String Nima?
• String yozilish turları ( ‘ ’, “ ”, ` `);
• str —> str[1]===str.charAt(1), concat(str) , +

  • \n\t\’\”, length, indexOf, lastIndexOf, search() returns index if found,

  • includes(str, index)

  • slice(startInd, (-)endInd)

  • substring(startInd,endInd)not including last element

  • substr(startInd, length) extract element including last index

  • replace(‘1’, ‘2’),

  • split(‘’), split(‘,’), repeat(times)

  • regex pattern —> /abs/ exact “abs”

  • regex = /[a-z]/g —> regex = /[A-Z]/g —> regex = /a/g regex=/a/i=> i case-insensitive // g=global

  • match(regex) // returns an array

  • padStart(length, ‘***’), padEnd(length, ‘…’)

const str1 = '5';
console.log(str1.padEnd(4, '0'));
console.log(str1.padStart(4, '0')); // first is length, second is the value to place

  • startsWith(searchString, position) // true or false

  • endsWith(searchString, position) // true or false

  • toLowerCase(), toUpperCase(),

  • str.trim()

4. JAVASCRIPT – Konstruktiv funksiyalar va date obekti
• Functions nima?
• Functions && Arrow functions
return and without return
parametrs, default parametrs
function multiply(a, b = 1) {
return a * b;
}
Recursive functions
// program to count down numbers to 1
function countDown(number) {


// display the number
console.log(number);


// decrease the number value
const newNumber = number - 1;


// base case
if (newNumber > 0) {
countDown(newNumber);
}
}
countDown(4);


// program to find the factorial of a number
function factorial(x) {


// if number is 0
if (x === 0) {
return 1;
}


// if number is positive
else {
return x * factorial(x - 1);
}
}

Date obekti bilan ishalsh



const d = new Date("2015-03-25");
const d = new Date("2015");
const d = new Date("03/25/2015");

getFullYear() Get the year as a four digit number (yyyy)


getMonth() Get the month as a number (0-11)
getDate() Get the day as a number (1-31)
getHours() Get the hour (0-23)
getMinutes() Get the minute (0-59)
getSeconds() Get the second (0-59)
getMilliseconds() Get the millisecond (0-999)
getTime() Get the time (milliseconds since January 1, 1970)
getDay() Get the weekday as a number (0-6)
Date.now() Get the time in milliseoncds. ECMAScript 5.

setDate() Set the day as a number (1-31)


setFullYear() Set the year (optionally month and day)
setHours() Set the hour (0-23)
setMilliseconds() Set the milliseconds (0-999)
setMinutes() Set the minutes (0-59)
setMonth() Set the month (0-11)
setSeconds() Set the seconds (0-59)
setTime() Set the time (milliseconds since January 1, 1970)

//get tomorrow


const date = new Date()
const tomorrowInDays = date.setDate(date.getDate() + 1)
new Date(tomorrowInDays)


Download 105.45 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   12




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling