javascript Array functions
AD MOB
Některé funkce pracující s polem v JavaScriptu
var myArray = []; // smazat obsah, nebo inicializovat nove pole
concat([item1[, item2[, . . . [, itemN]]]])
concat([string2[, string3[, . . . [, stringN]]]])
/* spoji stringy nebo pole a vraci novy string nebo pole */
join(separator)
/* vrati v string spojene itemy poli oddelene separatorem*/
push([item1 [item2 [. . . [itemN ]]]])
/* prida na konec pole novy item a vraci delku pole*/
pop()
/* odebere posledni element z pole a vrati jeho hodnotu*/
reverse()
/*vraci obracene poradi itemu pole*/
shift()
/* odebere prvni item z pole a vrati jej*/
slice(start, [end])
/* varaci cast pole*/
var numArray = new Array(3,2,5,9);
var newNumArray = numArray.slice(1,3); // 2,5
sort() // string
sort(sortFunction)
/* setridi pole cisel od nejvetsiho - descending */
sort(function(a, b){return b-a})
/* setridi od nejmensiho cisla - ascendant*/
sort(function(a, b){return a-b})
splice(start, deleteCount, [item1[, item2[, . . . [,itemN]]]])
/* odebere element z pole, popripade vlozi novy a vrati odebrany element*/
var numArray = new Array(3,2,5,9);
var newNumArray = numArray.splice(1,1); // 3,5,9
unshift([item1[, item2 [, . . . [, itemN]]]])
/* prida na pocatek item, ktery je parametrem funkce */
var myA = new Array(10,11,12);
myA.unshift(1); // 1,10,11,12
77LW NO topic_id
AD
Další témata ....(Topics)
For all browsers e.g. old IE 11 ....
<script>
var mbThreadOneRunning = false;
var mbThreadOneEnded = false;
var mbThreadTwoRunning = false;
var mbThreadTwoEnded = false;
// you can create more than one Thread
// setTimeout() used for running more Threads at once
var timeout_1 = setTimeout("ThreadOne()", 5000); // 5000 == 5 second
var timeout_2 = setTimeout("ThreadTwo()", 3000); //
function ThreadOne() {
mbThreadOneRunning = true;
alert("1. ThreadOne working!");
// working code here .............
mbThreadOneEnded = true;
clearTimeout(timeout_1);
}
function ThreadTwo() {
mbThreadTwoRunning = true;
alert("2. ThreadTwo working!");
// working code here .............
mbThreadTwoEnded = true;
clearTimeout(timeout_2);
}
var mInterval = setInterval("checkThread()", 1000); // 1000 ms == 1 second, you can put smaller value
function checkThread() {
if (mbThreadOneEnded == true) {
alert("1. checkThread() ThreadOne finish work! " + mbThreadOneEnded);
}
else if (mbThreadTwoEnded == true) {
alert("2. checkThread() ThreadTwo finish work! " + mbThreadTwoEnded);
}
if (mbThreadOneEnded && mbThreadTwoEnded) {
clearInterval(mInterval); // just to be sure
mbThreadOneEnded = false;
mbThreadTwoEnded = false;
alert("ThreadOne and ThreadTwo ended ");
}
}
</script>
Example code
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.newsite.com/new-page.php");
header("Connection: close");
exit();
If using file name without .php as part of smoothly url - example:
$fileName = basename(__FILE__, '.php');
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://www.mysite.cz/auto-moto/".$fileName."/");
header("Connection: close");
exit();
Date: 23.07.2020 - 12:31Tohle jsou některé metody objektu document
clear
createDocument
createDocumentFragment
createElement
createEvent
createEventObject
createRange
createTextNode
getElementById
/* nejpouzivanejsi metoda objektu document, ktera
ziska handle elementu dle jeho id*/
getElementByTagName
var e = document.getElementById('list');
e= e.getElementsByTagName('span');
i=0;
while(i < e.length){
e[i].style.color = "green";
}
write
document.write("some text");
Pokud chceme při kompilaci kódu zobrazit chybová hlášení,
odkomentujeme příslušné řádky v souboru php.ini, jehož adresu
získáme pomocí funkce phpinfo() a přepneme Off na On u
display_errors.
Podrobnosti se dočtete v komentářích k jednotlivým nastavením v php.ini
Podrobnosti se dočtete v komentářích k jednotlivým nastavením v php.ini
error_reporting = E_ALL & ~E_NOTICE // vypise i parse errors
display_errors = On
Editace: 30.1.2021 - 20:38
Počet článků v kategorii: 77
Url:javascript-array-functions
AD