@@ -232,93 +232,85 @@ alone. The next version of JavaScript will introduce a `let` keyword,
232232which works like `var` but creates a variable that is local to the
233233enclosing _block_, not the enclosing _function_.
234234
235- == Functions as values ==
235+ == Funksiyalar, dəyər kimi ==
236236
237- (((function,as value)))Function ((variable))s usually simply act as
238- names for a specific piece of the program. Such a variable is defined
239- once and never changed. This makes it easy to start confusing the
240- function and its name.
237+ (((function,as value)))Funksiya ((dəyişən))ləri əsasən müəyyən proqram
238+ hissəsi üçün ad kimi davranır. Belə dəyişən bir dəfə elan olunur ve heç vaxt
239+ dəyişilmir. Buna görə funksiyanı və onun adını qarışdırmaq çox asandır.
241240
242- (((variable,assignment)))But the two are different. A function value
243- can do all the things that other values can do—you can use it in
244- arbitrary ((expression))s, not just call it. It is possible to store a
245- function value in a new place, pass it as an argument to a function,
246- and so on. Similarly, a variable that holds a function is still just a
247- regular variable and can be assigned a new value, like so :
241+ (((variable,assignment)))Lakin bu iki anlayış fərqlidir. Funksiya
242+ dəyəri digər bütün dəyərlərin bacardığını edə bilir. Onu çağırmaqdan
243+ başqa, həm də ((ixtiyari)) ifadədə istifadə etmək olar. Funksiyanın
244+ dəyərini yeni yerdə saxlamaq, başqa funskiyaya arqument kimi ötürmək
245+ və s. olar. Funksiyanı saxlayan dəyişən eyni zamanda həm də adi bir
246+ dəyişən olduğu üçün ona aşağıdakı kimi yeni dəyər mənimsətmək olar :
248247
249248// test: no
250249
251250[source,javascript]
252251----
253- var launchMissiles = function(value) {
254- missileSystem.launch("now ");
252+ var raketleriIsheSal = function(value) {
253+ raketSistemi.isheSal("indi ");
255254};
256- if (safeMode )
257- launchMissiles = function(value) {/* do nothing */};
255+ if (tehlukesiz rejim )
256+ raketleriIsheSal = function(value) {/* heç nə etmə */};
258257----
259258
260- (((function,higher-order)))In
261- link:05_higher_order.html#higher_order[Chapter 5], we will discuss the
262- wonderful things that can be done by passing around function values to
263- other functions .
259+ (((function,higher-order)))
260+ link:05_higher_order.html#higher_order[Fəsil 5] -də funksiya dəyərini
261+ başqa funksiyalara ötürməklə necə möhtəşəm nəticələr ala biləyəcimizi
262+ müzakirə edəcəyik .
264263
265264== Elan qaydası ==
266265
267266(((syntax)))(((square example)))(((function
268267keyword)))(((function,definition)))(((function,declaration)))
269- “++var square = function…++” kimi yazmaqdan daha qısa üsul var.
268+ “++var kvadrat = function…++” kimi yazmaqdan daha qısa üsul var.
270269`function` açar sözü aşağıdakı nümunədəki kimi bəyanatın (statement)
271270əvvəlində də gələ bilər.
272271
273272[source,javascript]
274273----
275- function square (x) {
274+ function kvadrat (x) {
276275 return x * x;
277276}
278277----
279278
280279(((future)))(((execution order)))Bu funksiya _bəyanıdır_(declaration).
281- Bu bəyanat `square ` dəyişənini elan edir və verilmiş funksiyaya işarə
280+ Bu bəyanat `kvadrat ` dəyişənini elan edir və verilmiş funksiyaya işarə
282281edir. Bəyanatın bu cür formasında bir incə(sublety) məqam var.
283282
284283[source,javascript]
285284----
286- console.log("The future says :", future ());
285+ console.log("Gələcək deyir :", gelecek ());
287286
288- function future () {
289- return "We STILL have no flying cars .";
287+ function gelecek () {
288+ return "Hələ də uçan avtomobillərimiz yoxdur .";
290289}
291290----
292291
293- This code works, even though the function is defined _below_ the code
294- that uses it. This is because function declarations are not part of
295- the regular top-to-bottom flow of control. They are conceptually moved
296- to the top of their scope and can be used by all the code in that
297- scope. This is sometimes useful because it gives us the freedom to
298- order code in a way that seems meaningful, without worrying about
299- having to define all functions above their first use.
300- Baxmayaraq ki, funksiyanın elanı istifadəsindən _aşağıda_ yer alıb,
301- bu kod işləyir. Bu ona görədir ki, funksiya bəyanları adi yuxarıdan-
302- aşağıya nəzarət axınının (flow of control) bir hissəsi deyil. Onlar
292+ Baxmayaraq ki, funksiyanın elanı istifadəsindən _aşağıda_ yer alıb,
293+ bu kod işləyəcək. Bu ona görədir ki, funksiya bəyanları adi yuxarıdan-
294+ aşağıya nəzarət axınının (flow of control) bir hissəsi deyil. Onlar
303295konsept olaraq öz təsir çərçivəsininin(scope) yuxarısına köçürülür və həmin
304- çərçivədə bütün kodda istifadə oluna bilər. Bu bəzən yararlıdır, çünki
305- bu bizə kodu, funksiyaları kodun yuxarısında elan etdim bizimçün məntiqli olan istədiyimiz strukturla yazmaq imkanı
306- verir.
307-
308- (((function,declaration)))What happens when you put such a function
309- definition inside a conditional (`if`) block or a loop? Well, don't do
310- that. Different JavaScript platforms in different browsers have
311- traditionally done different things in that situation, and the latest
312- ((standard )) actually forbids it. If you want your programs to behave
313- consistently, only use this form of function-defining statements in
314- the outermost block of a function or program .
296+ çərçivə daxilində bütün kodda istifadə oluna bilər. Bu bəzən yararlıdır,
297+ çünki bu bizə kodu, funksiya bəyanlarını kodun yuxarısında və ya aşağısında
298+ yerləşdirməyimizdən asılı olmayaraq, bizə məntiqli görünən - istədiyimiz
299+ strukturla yazmaq imkanı verir.
300+
301+ (((function,declaration)))Bəs funksiya elanlarını şərt (`if`) və ya dövr
302+ blokuna yerləşdirdikdə nə baş verir? Bunu etməyin. Belə vəziyyətdə fərqli
303+ JavaScript platformaları fərqli brauzerlərdə müxtəlif nəticələr vermişlər
304+ və ən son ((standart )) bunu ümumiyyətlə qadağan edir. Əgər proqramınızın
305+ davamlı olmağını istəyirsinizsə, bu cür funksiya elanlarını ancaq
306+ funksiyanın və ya proqramın səvviyəcə ən üst blokunda edin .
315307
316308[source,javascript]
317309----
318- function example () {
319- function a() {} // Okay
320- if (something ) {
321- function b() {} // Danger !
310+ function numune () {
311+ function a() {} // OK
312+ if (nə isə ) {
313+ function b() {} // Təhlükə !
322314 }
323315}
324316----
@@ -327,129 +319,123 @@ function example() {
327319== The call stack ==
328320
329321indexsee:[stack,call stack]
330- (((call stack)))(((function,application)))It will be helpful to take a
331- closer look at the way control flows through functions. Here is a
332- simple program that makes a few function calls :
322+ (((call stack)))(((function,application)))Kodda ardıcıllığın(axın) necə təmin
323+ olunduğuna yaxından baxaq. Aşağıda bir neçə funksiya çağırışı edən kiçik
324+ proqrama baxaq :
333325
334326[source,javascript]
335327----
336- function greet(who ) {
337- console.log("Hello " + who );
328+ function salamla(kim ) {
329+ console.log("Salam " + kim );
338330}
339- greet("Harry ");
340- console.log("Bye ");
331+ salamla("Aysel ");
332+ console.log("Hələlik ");
341333----
342334
343- (((control flow)))(((execution order)))(((console.log)))A run through
344- this program goes roughly like this: the call to `greet` causes
345- control to jump to the start of that function (line 2). It calls
346- `console.log` (a built-in browser function), which takes control, does
347- its job, and then returns control to line 2. Then it reaches the end
348- of the `greet` function, so it returns to the place that called it, at
349- line 4. The line after that calls `console.log` again .
335+ (((control flow)))(((execution order)))(((console.log)))Burada nəzarət axını
336+ kobud olaraq belə baş verir: `salamla` funksiyasının çağırışı nəzarət axının
337+ funksiyanın başlanğıcına getməsinə səbəb olur (sətir 2). O da öz növbəsində
338+ nəzarət axınını ələ keçirən `console.log` -u (brauzer funksiyası) çağırır,
339+ öz işini görür və yenidən sətir 2-ə qayıdır. Bundan sonra `salamla` funksiyasının
340+ sonuna çatır, onun çağırıldığı sətirə, yəni 4-cü sətirə geri qayıdır. Bundan
341+ sonrakı sətir `console.log`-u yenidən çağırır .
350342
351- We could show the flow of control schematically like this :
343+ Sxematik olaraq bunu aşağıdakı kimi göstərmək olar :
352344
353345----
354- top
355- greet
346+ üst
347+ salamla
356348 console.log
357- greet
358- top
349+ salamla
350+ üst
359351 console.log
360- top
352+ üst
361353----
362354
363- (((return keyword)))(((memory)))Because a function has to jump back to
364- the place of the call when it returns, the computer must remember the
365- context from which the function was called. In one case, `console.log`
366- has to jump back to the `greet` function. In the other case, it jumps
367- back to the end of the program.
368-
369- The place where the computer stores this context is the _((call
370- stack))_. Every time a function is called, the current context is put
371- on top of this “stack”. When the function returns, it removes the top
372- context from the stack and uses it to continue execution.
373-
374- (((infinite loop)))(((stack overflow)))(((recursion)))Storing this
375- stack requires space in the computer's memory. When the stack grows
376- too big, the computer will fail with a message like “out of stack
377- space” or “too much recursion”. The following code illustrates this by
378- asking the computer a really hard question, which causes an infinite
379- back-and-forth between two functions. Rather, it _would_ be infinite,
380- if the computer had an infinite stack. As it is, we will run out of
381- space, or “blow the stack”.
355+ (((return keyword)))(((memory)))Funksiya çağırılıb yekunlaşdıqdan sonra
356+ nəzarət axını çağırıldığı sətirə geri qayıtdığına görə kompüter həmin
357+ konteksti yadda saxlamalıdır. Bir halda `console.log` `salamla` funksiyasına
358+ tullanır, digər halda isə proqramın sonuna aparır.
359+
360+ Kompüterin bu konteksti saxladığı yer isə _((sorğu steki))_ (call stack) adlanır.
361+ Hər dəfə funksiya çağırılanda, cari konktest bu “stekin” yuxarısına yerləşdirilir.
362+ Funksiyanın icrası başa çatdıqda ən üstdəki konktest stekdən kənarlaşdırılır
363+ və proqramın sonrakı icrası üçün istifadə olunur.
364+
365+ (((infinite loop)))(((stack overflow)))(((recursion)))Bu steki saxlamaq
366+ kompüterin yaddaşında yer tələb edir. Stek çox böyüdükcə kompüter “stek
367+ yaddaşı dolub” və ya “həddindən çox rekursiya” ismarıcı ilə səhv verə
368+ bilər (fail). Aşağıdakı kod bunu kompüterə çox çətin sual verməklə,
369+ iki funksiya arasında sonsuz önə-arxaya getməklə nümayiş etdirir.
370+ Kompüterin steki sonsuz olsaydı, sonsuz olaraq bu proses davam edəcəkdi.
371+ Olmadığına görə yaddaş “dolub daşacaq”.
382372
383373// test: no
384374
385375[source,javascript]
386376----
387- function chicken () {
388- return egg ();
377+ function toyuq () {
378+ return yumurta ();
389379}
390- function egg () {
391- return chicken ();
380+ function yumurta () {
381+ return toyuq ();
392382}
393- console.log(chicken () + " came first .");
383+ console.log(toyuq () + " birinci yaranıb .");
394384// → ??
395385----
396386
397- == Optional Arguments ==
387+ == Könüllü(optional) Arqumentlər ==
398388
399- (((argument)))(((function,application)))The following code is allowed
400- and executes without any problem:
389+ (((argument)))(((function,application)))Aşağıdakı kod səhvsiz icra olunur:
401390
402391[source,javascript]
403392----
404- alert("Hello ", "Good Evening ", "How do you do ?");
393+ alert("Salam ", "Axşamın xeyir ", "Necəsən ?");
405394----
406395
407- (((alert function)))The function `alert` officially accepts only one
408- argument. Yet when you call it like this, it doesn't complain. It
409- simply ignores the other arguments and shows you “Hello” .
396+ (((alert function)))`alert` funksiyası rəsmi olaraq yalnız bir arqument
397+ qəbul edir. Buna baxmayaraq belə çağırdıqda heç bir səhv baş vermir.
398+ Sadəcə digər arqumentlərə məhəl qoyulmur (ignores) və “Salam” çıxarır .
410399
411- (((undefined)))(((parameter)))JavaScript is extremely broad-minded
412- about the number of arguments you pass to a function. If you pass too
413- many, the extra ones are ignored. If you pass too few, the missing
414- parameters simply get assigned the value `undefined`.
400+ (((undefined)))(((parameter)))JavaScript funksiyaya ötürülən arqumentlərin
401+ sayına görə çox tolerantdır (broad-minded). Əgər lazımdan çox ötürmüsünüzsə,
402+ əlavələ sadəcə iqnor olunacaq, əksinə, lazımından az ötürülürsə, buraxılmış
403+ arqumentlərə sadəcə olaraq `undefined` mənimsədilir .
415404
416- The downside of this is that it is possible—likely, even—that you'll
417- accidentally pass the wrong number of arguments to functions and no
418- one will tell you about it.
405+ Bunun mənfi tərəfi odur ki, funksiyaya təsadüfən arqumentlərin sayını səhv
406+ ötürsəniz, heç kim sizə bu haqda deməyəcək.
419407
420408[[power]]
421- (((power example)))(((optional argument)))The
422- upside is that this behavior can be used to have a function take
423- “optional” arguments. For example, the following version of `power`
424- can be called either with two arguments or with a single argument, in
425- which case the exponent is assumed to be two, and the function behaves
426- like `square`.
409+ (((power example)))(((optional argument)))Üstün tərəfi isə odur ki,
410+ “könüllü” (“optional”) arqumentlər yarada bilərik. Məsələn, `quvvet` -in
411+ aşağıdakı versiyası iki arqumentlə də, bir arqumentlə də icra oluna bilər.
412+ Bir arqumentli halda eksponent iki götürülür və `kvadrat` funksiyası kimi
413+ davranır.
427414
428415// test: wrap
429416
430417[source,javascript]
431418----
432- function power(base, exponent ) {
433- if (exponent == undefined)
434- exponent = 2;
435- var result = 1;
436- for (var count = 0; count < exponent; count ++)
437- result *= base ;
438- return result ;
419+ function quvvet(esas, eksponent ) {
420+ if (eksponent == undefined)
421+ eksponent = 2;
422+ var netice = 1;
423+ for (var say = 0; say < eksponent; say ++)
424+ netice *= esas ;
425+ return netice ;
439426}
440427
441- console.log(power (4));
428+ console.log(quvvet (4));
442429// → 16
443- console.log(power (4, 3));
430+ console.log(quvvet (4, 3));
444431// → 64
445432----
446433
447- (((console.log)))In the link:04_data.html#arguments_object[next
448- chapter], we will see a way in which a function body can get at the
449- exact list of arguments that were passed. This is helpful because it
450- makes it possible for a function to accept any number of arguments.
451- For example, `console.log` makes use of this—it outputs all of the
452- values it is given.
434+ (((console.log)))In the link:04_data.html#arguments_object[Növbəti
435+ fəsildə] funksiyanın gövdəsinin ötürülən arqumentlərin sayını necə
436+ dəqiq müəyyənləşdirdiyini görəcəyik. İstədiyimiz sayda arqument
437+ ötürə bilmək cəhətdən bu çox yararlıdır. `console.log` bundan
438+ istifadə edərək ötürdüyümüz bütün arqumentləri çap edir.
453439
454440[source,javascript]
455441----
0 commit comments